﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;
using System.Net.NetworkInformation;

namespace TestDxfDocument
{

    class Tapdetail
    {
        public static void Fineshankedtaps(Dictionary<string, Object> data)//细柄丝锥
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double fdc = Convert.ToDouble(data["fdc"]);
            string path = Convert.ToString(data["path"]);
            string code = Convert.ToString(data["tdz"]);
            // 非空判断
            if (data["lu"].Equals("")) data["lu"] = 0;
            if (data["dn"].Equals("")) data["dn"] = 0;

            if (fdc == 0)
            {
                double soal = Convert.ToDouble(data["oal"]);
                double scale = Convert.ToDouble(data["scale"]); //放大系数
                if (scale == 0 && soal < 105)
                {
                    scale = 2.0;
                }
                else if (scale == 0 && soal < 210)
                {
                    scale = 1.0;
                }
                else if (scale == 0)
                {
                    scale = 0.5;
                }
                double pi = Math.PI;
                double td = Convert.ToDouble(data["td"]) * scale;
                double dmm = Convert.ToDouble(data["dconms"]) * scale;
                double tp = Convert.ToDouble(data["tp"]) * scale;
                double dn = Convert.ToDouble(data["dn"]) * scale;
                if (dn == 0)
                {
                    dn = td - 1.1325 * tp - 0.15;
                }
                double mc = Convert.ToDouble(data["mc"]);
                double qxzj;
                if (mc == 0)
                {
                    qxzj = 4.5 * pi / 180;
                }
                if (mc == 1)
                {
                    qxzj = 8.5 * pi / 180;
                }
                if (mc == 2)
                {
                    qxzj = 17 * pi / 180;
                }
                else
                {
                    qxzj = 6 * pi / 180;
                }

                double tcl;
                if (mc == 0)
                {
                    tcl = 8 * tp;
                }
                else if (mc == 1)
                {
                    tcl = 4 * tp;
                }
                else if (mc == 2)
                {
                    tcl = 2 * tp;
                }
                else
                {
                    tcl = 6 * tp;
                }

                if (tcl == 0)
                {
                    tcl = tp * 2.3;
                }
                double tcpd = td - tcl * Math.Tan(qxzj);
                /*
                double tcpd = Convert.ToDouble(data["tcpd"]) * scale;
                if (tcpd == 0)
                {
                    tcpd = td - tp * 1.13;
                }
                double tcl = Convert.ToDouble(data["tcl"]) * scale;
                if (tcl == 0)
                {
                    tcl = tp * 3;
                }*/
                double wcf = Convert.ToDouble(data["wcf"]) * scale;
                if (wcf == 0)
                {
                    wcf = td / 3;
                }
                double thl = Convert.ToDouble(data["thl"]) * scale;
                double lu = Convert.ToDouble(data["lu"]) * scale;
                if (lu == 0)
                {
                    lu = thl * 39 / 22;
                }
                double oal = Convert.ToDouble(data["oal"]) * scale;
                double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
                double drvl = Convert.ToDouble(data["drvl"]) * scale;
                /*double d7 = 2.1 * scale;
                double d8 = 1 * scale;
                double d9 = 2.5 * scale;
                double d10 = 1.2 * scale;
                double l4 = 2.6 * scale;*/
                double ds = dmm - 0.08 * scale;//柄方外圆
                double isframe = Convert.ToDouble(data["isframe"]);
                //坐标
                //主视图
                Vector2 v2 = new Vector2(-oal / 2.00, tcpd / 2.00);
                Vector2 v3 = new Vector2(v2.X + tcl, td / 2.00);
                Vector2 v4 = new Vector2(v2.X + thl, v3.Y);
                Vector2 v5 = new Vector2((td - dn) / 2.00 + v4.X, dn / 2.00);
                Vector2 v6 = new Vector2(v2.X + lu, v5.Y);
                Vector2 v7 = new Vector2(v6.X, dmm / 2.00);
                Vector2 v8 = new Vector2(v2.X + oal - 0.15 * dmm, ds / 2);
                Vector2 v9 = new Vector2(v2.X + oal, 0.35 * dmm);
                Vector2 v10 = new Vector2(v9.X, -v9.Y);
                Vector2 v11 = new Vector2(v8.X, -v8.Y);
                Vector2 v12 = new Vector2(v7.X, -v7.Y);
                Vector2 v13 = new Vector2(v6.X, -v6.Y);
                Vector2 v14 = new Vector2(v5.X, -v5.Y);
                Vector2 v15 = new Vector2(v4.X, -v4.Y);
                Vector2 v16 = new Vector2(v3.X, -v3.Y);
                Vector2 v17 = new Vector2(v2.X, -v2.Y);
                Vector2 v19 = new Vector2(v8.X - drvl, dmm / 15.6875);
                Vector2 v18 = new Vector2(v19.X, v8.Y);
                Vector2 v20 = new Vector2(v8.X, v19.Y);
                Vector2 v21 = new Vector2(v20.X, v18.Y);
                Vector2 v22 = new Vector2(v21.X - (v18.Y - v19.Y) / 2.00 * Math.Tan(60 * pi / 180), (v18.Y + v19.Y) / 2.00);
                Vector2 v23 = new Vector2(v18.X, -v18.Y);
                Vector2 v24 = new Vector2(v19.X, -v19.Y);
                Vector2 v25 = new Vector2(v20.X, -v20.Y);
                Vector2 v26 = new Vector2(v21.X, -v21.Y);
                Vector2 v27 = new Vector2(v22.X, -v22.Y);
                Vector2 v28 = new Vector2(v2.X + lu - 3, 0);
                Vector2 v29 = new Vector2(v2.X + lu - 2 * wcf / 3.00 - 3, wcf / 3.00);
                Vector2 v30 = new Vector2(v2.X + lu - 3 * wcf / 2.00 - 3, wcf / 2.00);
                Vector2 v31 = new Vector2(v30.X, -v30.Y);
                Vector2 v32 = new Vector2(v29.X, -v29.Y);
                Vector2 v33 = new Vector2(v2.X, v30.Y);
                Vector2 v34 = new Vector2(v33.X, -v33.Y);
                double dx = v2.X;
                if (tcpd < dn)
                {
                    dx = (v5.Y - oal * (td - tcpd) / 4 / tcl - tcpd / 2) * 2 * tcl / (td - tcpd);
                }
                Vector2 v35 = new Vector2(dx, v5.Y);
                Vector2 v36 = new Vector2(dx, v14.Y);
                Vector2 v37 = new Vector2(v4.X, v34.Y);
                Vector2 v38 = new Vector2(v37.X, -v37.Y);
                Vector2 v39 = new Vector2(v5.X, v38.Y);
                Vector2 v40 = new Vector2(v39.X, -v39.Y);
                Vector2 v41 = new Vector2(v2.X - 2, 0);
                Vector2 v42 = new Vector2(v9.X + 2, 0);
                Vector2 v80 = new Vector2(v8.X - drvl - 1 * scale, v7.Y);
                Vector2 v81 = new Vector2(v80.X, -v80.Y);
                Vector2 v82 = new Vector2(v80.X, ds / 2.00);
                Vector2 v83 = new Vector2(v82.X, -v82.Y);
                //柄方
                Vector2 v45 = new Vector2(105 + oal / 4.00, v8.Y - (v20.Y - v25.Y) * Math.Cos(45 * pi / 180));
                Vector2 v46 = new Vector2(v45.X - (v20.Y - v25.Y) / 2.00, v45.Y + (v20.Y - v25.Y) / 2.00);
                Vector2 v47 = new Vector2(v45.X * 2 - v46.X, v46.Y);
                Vector2 v48 = new Vector2(v45.X + v45.Y, 0);
                Vector2 v49 = new Vector2(v45.X + v46.Y, v48.Y + v47.X - v45.X);
                Vector2 v50 = new Vector2(v49.X, -v49.Y);
                Vector2 v51 = new Vector2(v45.X, -v45.Y);
                Vector2 v52 = new Vector2(v47.X, -v47.Y);
                Vector2 v53 = new Vector2(v46.X, -v46.Y);
                Vector2 v54 = new Vector2(v45.X * 2 - v48.X, v48.Y);
                Vector2 v55 = new Vector2(v45.X * 2 - v50.X, v50.Y);
                Vector2 v56 = new Vector2(v45.X * 2 - v49.X, v49.Y);
                Vector2 v57 = new Vector2(v45.X - ds / 2.00 - 2, 0);
                Vector2 v58 = new Vector2(v45.X + ds / 2.00 + 2, 0);
                Vector2 v59 = new Vector2(v45.X, ds / 2.00 + 2);
                Vector2 v60 = new Vector2(v59.X, -v59.Y);
                /*//定位孔1
                Vector2 v65 = new Vector2(v2.X, d7 / 2.00);
                Vector2 v66 = new Vector2((d7 - d8) / 2.00 * Math.Tan(60 * pi / 180) + v65.X, d8 / 2.00);
                Vector2 v67 = new Vector2(v65.X + l4, v66.Y);
                Vector2 v68 = new Vector2(d8 / 2.00 / Math.Tan(60 * pi / 180) + v67.X, 0);
                Vector2 v69 = new Vector2(v67.X, -v67.Y);
                Vector2 v70 = new Vector2(v66.X, -v66.Y);
                Vector2 v71 = new Vector2(v65.X, -v65.Y);
                //定位孔2
                Vector2 v72 = new Vector2(v9.X, d9 / 2.00);
                Vector2 v73 = new Vector2(v72.X - (d9 - d10) / 2.00 * Math.Tan(60 * pi / 180), d10 / 2.00);
                Vector2 v74 = new Vector2(v72.X - l4, v73.Y);
                Vector2 v75 = new Vector2(v74.X - d10 / 2.00 / Math.Tan(60 * pi / 180), 0);
                Vector2 v76 = new Vector2(v74.X, -v74.Y);
                Vector2 v77 = new Vector2(v73.X, -v73.Y);
                Vector2 v78 = new Vector2(v72.X, -v72.Y);*/
                //线段
                //主视图
                /*
                string tctr = Convert.ToString(data["tctr"]);
                 if (!tctr.Equals("0"))*/
                string tctr = Convert.ToString(data["tctr"]);
                if (!tctr.Equals("0"))
                {
                    Vector2 a1 = fun.Polar(v3, fun.CalAngle(v3, v4), fun.CalDistance(v3, v4) / 2);
                    Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                    Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                    Line line101 = new Line(a1, a2);
                    dxf.AddEntity(line101);
                    fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

                }


                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v80 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v81, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line18 = { v2, v17 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v4, v38 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v37, v15 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v5, v39 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v40, v14 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v6, v13 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v7, v12 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v8, v21 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v20, v25 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v26, v11 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v21, v18 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v18, v19 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v19, v20 };
                fun.drawBLine(dxf, Line30, 0.3, contour);
                Vector2[] Line31 = { v25, v24 };
                fun.drawBLine(dxf, Line31, 0.3, contour);
                Vector2[] Line32 = { v24, v23 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v23, v26 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                //Arc Arc1 = new Arc(v22, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
                //Arc Arc2 = new Arc(v27, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v21));
                Arc1.Vertexes.Add(new LwPolylineVertex(v20));
                Arc1.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v25));
                Arc2.Vertexes.Add(new LwPolylineVertex(v26));
                Arc2.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);

                fun.PolyFill(dxf, Arc2, 0.3, contour);
                LwPolyline Arc4 = new LwPolyline();
                Arc4.Vertexes.Add(new LwPolylineVertex(v18));
                Arc4.Vertexes.Add(new LwPolylineVertex(v19));
                Arc4.Vertexes[0].Bulge = 1 * scale / ((v18.Y - v19.Y) / 2.00);
                fun.PolyFill(dxf, Arc4, 0.3, contour);
                LwPolyline Arc5 = new LwPolyline();
                Arc5.Vertexes.Add(new LwPolylineVertex(v24));
                Arc5.Vertexes.Add(new LwPolylineVertex(v23));
                Arc5.Vertexes[0].Bulge = 1 * scale / ((v24.Y - v23.Y) / 2.00);
                fun.PolyFill(dxf, Arc5, 0.3, contour);
                Line line34 = new Line(v5, v35);
                line34.Lineweight = Lineweight.W25;
                line34.Layer = additionalline;
                dxf.AddEntity(line34);
                Line line35 = new Line(v14, v36);
                line35.Lineweight = Lineweight.W25;
                line35.Layer = additionalline;
                dxf.AddEntity(line35);
                Line Line36 = new Line(v34, v31);
                Line36.Layer = contour;
                dxf.AddEntity(Line36);
                Line Line37 = new Line(v33, v30);
                Line37.Layer = contour;
                dxf.AddEntity(Line37);
                Vector2[] Line38 = { v41, v42 };
                fun.drawPlinetype(dxf, Line38, 0.15, centre, Linetype.Center);
                Vector2[] Line39 = { v18, v20 };
                fun.drawBLine(dxf, Line39, 0.15, contour);
                Vector2[] Line40 = { v19, v21 };
                fun.drawBLine(dxf, Line40, 0.15, contour);
                Vector2[] Line41 = { v24, v26 };
                fun.drawBLine(dxf, Line41, 0.15, contour);
                Vector2[] Line42 = { v23, v25 };
                fun.drawBLine(dxf, Line42, 0.15, contour);
                List<Vector3> point1 = new List<Vector3>
            {
                fun.Tothree(v31),
                fun.Tothree(v32),
                fun.Tothree(v28),
                fun.Tothree(v29),
                fun.Tothree(v30),
            };
                Spline spline1 = new Spline(point1);
                spline1.Layer = contour;
                dxf.AddEntity(spline1);
                Vector2[] Line55 = { v80, v81 };
                fun.drawBLine(dxf, Line55, 0.3, contour);
                Vector2[] Line56 = { v82, v8 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v83, v11 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                //柄方
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v47));
                poly1.Vertexes.Add(new LwPolylineVertex(v49));
                poly1.Vertexes.Add(new LwPolylineVertex(v50));
                poly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v52));
                poly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v53));
                poly1.Vertexes.Add(new LwPolylineVertex(v55));
                poly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v56));
                poly1.Vertexes.Add(new LwPolylineVertex(v46));
                poly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.3, contour);
                Line Line53 = new Line(v57, v58);
                Line Line54 = new Line(v59, v60);
                /*//定位孔1
                Vector2[] Line55 = { v65, v66 };
                fun.drawPlinetype(dxf, Line55, refin, Linetype.Dashed);
                Vector2[] Line56 = { v66, v67 };
                fun.drawPlinetype(dxf, Line56, refin, Linetype.Dashed);
                Vector2[] Line57 = { v67, v68 };
                fun.drawPlinetype(dxf, Line57, refin, Linetype.Dashed);
                Vector2[] Line58 = { v68, v69 };
                fun.drawPlinetype(dxf, Line58, refin, Linetype.Dashed);
                Vector2[] Line59 = { v69, v70 };
                fun.drawPlinetype(dxf, Line59, refin, Linetype.Dashed);
                Vector2[] Line60 = { v70, v71 };
                fun.drawPlinetype(dxf, Line60, refin, Linetype.Dashed);
                Vector2[] Line67 = { v66, v70 };
                fun.drawPlinetype(dxf, Line67, refin, Linetype.Dashed);
                Vector2[] Line68 = { v67, v69 };
                fun.drawPlinetype(dxf, Line68, refin, Linetype.Dashed);
                //定位孔2
                Vector2[] Line61 = { v72, v73 };
                fun.drawPlinetype(dxf, Line61, refin, Linetype.Dashed);
                Vector2[] Line62 = { v73, v74 };
                fun.drawPlinetype(dxf, Line62, refin, Linetype.Dashed);
                Vector2[] Line63 = { v74, v75 };
                fun.drawPlinetype(dxf, Line63, refin, Linetype.Dashed);
                Vector2[] Line64 = { v75, v76 };
                fun.drawPlinetype(dxf, Line64, refin, Linetype.Dashed);
                Vector2[] Line65 = { v76, v77 };
                fun.drawPlinetype(dxf, Line65, refin, Linetype.Dashed);
                Vector2[] Line66 = { v77, v78 };
                fun.drawPlinetype(dxf, Line66, refin, Linetype.Dashed);
                Vector2[] Line69 = { v74, v76 };
                fun.drawPlinetype(dxf, Line69, refin, Linetype.Dashed);
                Vector2[] Line70 = { v73, v77 };
                fun.drawPlinetype(dxf, Line70, refin, Linetype.Dashed);*/
                //柄方图层
                Line53.Layer = centre;
                Line54.Layer = centre;
                Line53.Linetype = Linetype.Center;
                Line54.Linetype = Linetype.Center;
                //柄方
                dxf.AddEntity(Line53);
                dxf.AddEntity(Line54);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 1;
                dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 2.5;
                double offset = 20;
                //线段尺寸标注
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v3, v16), -v3.X + v2.X - offset, 270, dimensionStyle);
                dim2.UserText = "TD = " + Math.Round(td / scale, 2);
                dxf.AddEntity(dim2);

                string l5;
                string kr;

                if (mc == 0) { l5 = "8P"; kr = "4°30′"; }
                else if (mc == 1) { l5 = "4P"; kr = "8°30′"; }
                else if (mc == 2) { l5 = "2P"; kr = "17°"; }
                else if (mc == 3) { l5 = "6P"; kr = "6°"; }
                else { l5 = ""; kr = ""; }

                if (mc == 3 && tp > 2.5)
                {
                    Line line01 = new Line(fun.Polar(v80, pi, 4), fun.Polar(v81, pi, 4)); fun.drawBline(dxf, line01, 0.3, contour);
                }
                if (mc == 1 && tp > 2.5)
                {
                    Line line01 = new Line(fun.Polar(v80, pi, 4), fun.Polar(v81, pi, 4)); fun.drawBline(dxf, line01, 0.3, contour);
                    Line line02 = new Line(fun.Polar(v80, pi, 6.5), fun.Polar(v81, pi, 6.5)); fun.drawBline(dxf, line02, 0.3, contour);
                }

                LinearDimension dim00 = new LinearDimension(new Line(v3, v2), offset, 0, dimensionStyle);
                dim00.UserText = "TCL = " + l5;
                dxf.AddEntity(dim00);

                fun.jdbz2(dxf, new Line(v3, v4), new Line(v2, v3), offset, 2.5, 2, 0.6, "KAPR=" + kr, "", "");

                //尺寸3

                double toh = Convert.ToDouble(data["thltctrh"]);
                double tol = Convert.ToDouble(data["thltctrl"]);
                if (toh == 0 && tol == 0)
                {
                    LinearDimension dim3 = new LinearDimension(new Line(v17, v15), -offset * 1 / 2, 0, dimensionStyle);
                    dim3.UserText = "THL = " + Math.Round(thl / scale, 2);
                    dxf.AddEntity(dim3);
                }
                else
                {
                    fun.dimrot(dxf, v17, v15, 0, -offset * 1 / 2, 2.5, 2, 2.5, "THL = " + Math.Round(thl / scale, 2), toh + "", tol + "");
                }

                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v17, v13), -offset - 5, 0, dimensionStyle);
                dim4.UserText = "LU = " + Math.Round(lu / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5

                double toh1 = Convert.ToDouble(data["oaltctrh"]);
                double tol1 = Convert.ToDouble(data["oaltctrl"]);
                string oaltctr = Convert.ToString(data["oaltctr"]);
                if (toh1 == 0 && tol1 == 0)
                {

                    if (oaltctr.Equals("0"))
                    {
                        LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 2, 0, dimensionStyle);
                        dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                        dxf.AddEntity(dim5);
                    }
                    else
                    {
                        LinearDimension dim7 = new LinearDimension(new Line(v17, v10), -offset * 2, 0, dimensionStyle);
                        dim7.UserText = "OAL = " + Math.Round(oal / scale, 2) + "  " + oaltctr;
                        dxf.AddEntity(dim7);
                    }

                }
                else
                {
                    fun.dimrot(dxf, v17, v10, 0, -offset * 2, 2.5, 2, 2.5, "OAL = " + Math.Round(oal / scale, 2), toh1 + "", tol1 + "");
                }


                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v23, v26), -offset - (v26.Y - v11.Y), 0, dimensionStyle);
                dim6.UserText = "DRVL = " + Math.Round(drvl / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7



                string tcdconws = Convert.ToString(data["tcdconws"]);
                if (tcdconws.Equals("0"))
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                    dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2);
                    dxf.AddEntity(dim7);
                }
                else
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                    dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2) + "  " + tcdconws;
                    dxf.AddEntity(dim7);
                }
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v46, v50), -offset, 135, dimensionStyle);
                dim8.UserText = "DRVSC = " + Math.Round(drvsc / scale, 2);
                dxf.AddEntity(dim8);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
                hatchpoly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
                hatchpoly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
                hatchpoly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
                hatchpoly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 89, 10, hline1, harc1, hatching);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v2.X - 210 + (v45.X + v8.Y - v2.X) / 2.00, 148.5), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (fdc == 1)
            {
                double soal = Convert.ToDouble(data["oal"]);
                double scale = Convert.ToDouble(data["scale"]); //放大系数
                if (scale == 0 && soal < 105)
                {
                    scale = 2.0;
                }
                else if (scale == 0 && soal < 210)
                {
                    scale = 1.0;
                }
                else if (scale == 0)
                {
                    scale = 0.5;
                }
                double pi = Math.PI;
                double td = Convert.ToDouble(data["td"]) * scale;
                double dmm = Convert.ToDouble(data["dmm"]) * scale;
                double tp = Convert.ToDouble(data["tp"]) * scale;
                double dn = Convert.ToDouble(data["dn"]) * scale;
                if (dn == 0)
                {
                    dn = td - 1.1325 * tp - 0.15;
                }
                double mc = Convert.ToDouble(data["mc"]);
                double qxzj;
                if (mc == 0)
                {
                    qxzj = 4.5 * pi / 180;
                }
                if (mc == 1)
                {
                    qxzj = 8.5 * pi / 180;
                }
                if (mc == 2)
                {
                    qxzj = 17 * pi / 180;
                }
                else
                {
                    qxzj = 6 * pi / 180;
                }

                double tcl;
                if (mc == 0)
                {
                    tcl = 8 * tp;
                }
                else if (mc == 1)
                {
                    tcl = 4 * tp;
                }
                else if (mc == 2)
                {
                    tcl = 2 * tp;
                }
                else
                {
                    tcl = 6 * tp;
                }

                if (tcl == 0)
                {
                    tcl = tp * 2.3;
                }
                double tcpd = td - tcl * Math.Tan(qxzj);
                double thl = Convert.ToDouble(data["thl"]) * scale;
                double lu = Convert.ToDouble(data["lu"]) * scale;
                if (lu == 0)
                {
                    lu = thl * 39 / 22;
                }
                double oal = Convert.ToDouble(data["oal"]) * scale;
                double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
                double drvl = Convert.ToDouble(data["drvl"]) * scale;
                double FHA = Convert.ToDouble(data["fha"]);
                /*double d7 = 2.1 * scale;
                double d8 = 1 * scale;
                double d9 = 2.5 * scale;
                double d10 = 1.2 * scale;
                double l4 = 2.6 * scale;*/
                double ds = dmm - 0.08 * scale;//柄方外圆
                double isframe = Convert.ToDouble(data["isframe"]);
                //坐标
                //主视图
                Vector2 v2 = new Vector2(-oal / 2.00, tcpd / 2.00);
                Vector2 v3 = new Vector2(v2.X + tcl, td / 2.00);
                Vector2 v4 = new Vector2(v2.X + thl, v3.Y);
                Vector2 v5 = new Vector2((td - dn) / 2.00 + v4.X, dn / 2.00);
                Vector2 v6 = new Vector2(v2.X + lu, v5.Y);
                Vector2 v7 = new Vector2(v6.X, dmm / 2.00);
                Vector2 v8 = new Vector2(v2.X + oal - 0.15 * dmm, ds / 2);
                Vector2 v9 = new Vector2(v2.X + oal, 0.35 * dmm);
                Vector2 v10 = new Vector2(v9.X, -v9.Y);
                Vector2 v11 = new Vector2(v8.X, -v8.Y);
                Vector2 v12 = new Vector2(v7.X, -v7.Y);
                Vector2 v13 = new Vector2(v6.X, -v6.Y);
                Vector2 v14 = new Vector2(v5.X, -v5.Y);
                Vector2 v15 = new Vector2(v4.X, -v4.Y);
                Vector2 v16 = new Vector2(v3.X, -v3.Y);
                Vector2 v17 = new Vector2(v2.X, -v2.Y);
                Vector2 v19 = new Vector2(v8.X - drvl, ds / 2.00 * (Math.Sin(45 * pi / 180) * drvsc / ds - Math.Cos(45 * pi / 180) * Math.Sqrt(1 - (drvsc * drvsc) / (ds * ds))));
                Vector2 v18 = new Vector2(v19.X, drvsc * Math.Sin(45 * pi / 180) - v19.Y);
                Vector2 v20 = new Vector2(v8.X, v19.Y);
                Vector2 v21 = new Vector2(v20.X, v18.Y);
                Vector2 v22 = new Vector2(v21.X - (v18.Y - v19.Y) / 2.00 * Math.Tan(60 * pi / 180), (v18.Y + v19.Y) / 2.00);
                Vector2 v23 = new Vector2(v18.X, -v18.Y);
                Vector2 v24 = new Vector2(v19.X, -v19.Y);
                Vector2 v25 = new Vector2(v20.X, -v20.Y);
                Vector2 v26 = new Vector2(v21.X, -v21.Y);
                Vector2 v27 = new Vector2(v22.X, -v22.Y);
                Vector2 v41 = new Vector2(v2.X - 2, 0);
                Vector2 v42 = new Vector2(v9.X + 2, 0);
                Vector2 v80 = new Vector2(v8.X - drvl - 1 * scale, v7.Y);
                Vector2 v81 = new Vector2(v80.X, -v80.Y);
                Vector2 v82 = new Vector2(v80.X, ds / 2.00);
                Vector2 v83 = new Vector2(v82.X, -v82.Y);
                //柄方
                Vector2 v45 = new Vector2(105 + oal / 4.00, v8.Y - (v20.Y - v25.Y) * Math.Cos(45 * pi / 180));
                Vector2 v46 = new Vector2(v45.X - (v20.Y - v25.Y) / 2.00, v45.Y + (v20.Y - v25.Y) / 2.00);
                Vector2 v47 = new Vector2(v45.X * 2 - v46.X, v46.Y);
                Vector2 v48 = new Vector2(v45.X + v45.Y, 0);
                Vector2 v49 = new Vector2(v45.X + v46.Y, v48.Y + v47.X - v45.X);
                Vector2 v50 = new Vector2(v49.X, -v49.Y);
                Vector2 v51 = new Vector2(v45.X, -v45.Y);
                Vector2 v52 = new Vector2(v47.X, -v47.Y);
                Vector2 v53 = new Vector2(v46.X, -v46.Y);
                Vector2 v54 = new Vector2(v45.X * 2 - v48.X, v48.Y);
                Vector2 v55 = new Vector2(v45.X * 2 - v50.X, v50.Y);
                Vector2 v56 = new Vector2(v45.X * 2 - v49.X, v49.Y);
                Vector2 v57 = new Vector2(v45.X - ds / 2.00 - 2, 0);
                Vector2 v58 = new Vector2(v45.X + ds / 2.00 + 2, 0);
                Vector2 v59 = new Vector2(v45.X, ds / 2.00 + 2);
                Vector2 v60 = new Vector2(v59.X, -v59.Y);

                string tctr = Convert.ToString(data["tctr"]);
                if (!tctr.Equals("0"))
                {
                    Vector2 a1 = fun.Polar(v3, fun.CalAngle(v3, v4), fun.CalDistance(v3, v4) / 2);
                    Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                    Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                    Line line101 = new Line(a1, a2);
                    dxf.AddEntity(line101);
                    fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

                }
                /*//定位孔1
                Vector2 v61 = new Vector2(v2.X, d7 / 2.00);
                Vector2 v62 = new Vector2((d7 - d8) / 2.00 * Math.Tan(60 * pi / 180) + v61.X, d8 / 2.00);
                Vector2 v63 = new Vector2(v61.X + l4, v62.Y);
                Vector2 v64 = new Vector2(d8 / 2.00 / Math.Tan(60 * pi / 180) + v63.X, 0);
                Vector2 v65 = new Vector2(v63.X, -v63.Y);
                Vector2 v66 = new Vector2(v62.X, -v62.Y);
                Vector2 v67 = new Vector2(v61.X, -v61.Y);
                //定位孔2
                Vector2 v68 = new Vector2(v9.X, d9 / 2.00);
                Vector2 v69 = new Vector2(v68.X - (d9 - d10) / 2.00 * Math.Tan(60 * pi / 180), d10 / 2.00);
                Vector2 v70 = new Vector2(v68.X - l4, v69.Y);
                Vector2 v71 = new Vector2(v70.X - d10 / 2.00 / Math.Tan(60 * pi / 180), 0);
                Vector2 v72 = new Vector2(v70.X, -v70.Y);
                Vector2 v73 = new Vector2(v69.X, -v69.Y);
                Vector2 v74 = new Vector2(v68.X, -v68.Y);*/
                //线段
                double dx = v2.X;
                if (tcpd < dn)
                {
                    dx = (v5.Y - oal * (td - tcpd) / 4 / tcl - tcpd / 2) * 2 * tcl / (td - tcpd);
                }
                Vector2 v35 = new Vector2(dx, v5.Y);
                Vector2 v36 = new Vector2(dx, v14.Y);
                Line line34 = new Line(v5, v35);
                line34.Lineweight = Lineweight.W25;
                line34.Layer = additionalline;
                dxf.AddEntity(line34);
                Line line35 = new Line(v14, v36);
                line35.Lineweight = Lineweight.W25;
                line35.Layer = additionalline;
                dxf.AddEntity(line35);
                //主视图

                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v80 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v81, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line18 = { v2, v17 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line23 = { v6, v13 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v7, v12 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v8, v21 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v20, v25 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v26, v11 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v21, v18 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v18, v19 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v19, v20 };
                fun.drawBLine(dxf, Line30, 0.3, contour);
                Vector2[] Line31 = { v25, v24 };
                fun.drawBLine(dxf, Line31, 0.3, contour);
                Vector2[] Line32 = { v24, v23 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v23, v26 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                //Arc Arc1 = new Arc(v22, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
                //Arc Arc2 = new Arc(v27, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v21));
                Arc1.Vertexes.Add(new LwPolylineVertex(v20));
                Arc1.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v25));
                Arc2.Vertexes.Add(new LwPolylineVertex(v26));
                Arc2.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                LwPolyline Arc4 = new LwPolyline();
                Arc4.Vertexes.Add(new LwPolylineVertex(v18));
                Arc4.Vertexes.Add(new LwPolylineVertex(v19));
                Arc4.Vertexes[0].Bulge = 1 * scale / ((v18.Y - v19.Y) / 2.00);
                fun.PolyFill(dxf, Arc4, 0.3, contour);
                LwPolyline Arc5 = new LwPolyline();
                Arc5.Vertexes.Add(new LwPolylineVertex(v24));
                Arc5.Vertexes.Add(new LwPolylineVertex(v23));
                Arc5.Vertexes[0].Bulge = 1 * scale / ((v24.Y - v23.Y) / 2.00);
                fun.PolyFill(dxf, Arc5, 0.3, contour);
                Vector2[] Line38 = { v41, v42 };
                fun.drawPlinetype(dxf, Line38, 0.15, centre, Linetype.Center);
                Vector2[] Line39 = { v18, v20 };
                fun.drawBLine(dxf, Line39, 0.15, contour);
                Vector2[] Line40 = { v19, v21 };
                fun.drawBLine(dxf, Line40, 0.15, contour);
                Vector2[] Line41 = { v24, v26 };
                fun.drawBLine(dxf, Line41, 0.15, contour);
                Vector2[] Line42 = { v23, v25 };
                fun.drawBLine(dxf, Line42, 0.15, contour);
                Vector2[] Line55 = { v80, v81 };
                fun.drawBLine(dxf, Line55, 0.3, contour);
                Vector2[] Line56 = { v82, v8 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v83, v11 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                //柄方
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v47));
                poly1.Vertexes.Add(new LwPolylineVertex(v49));
                poly1.Vertexes.Add(new LwPolylineVertex(v50));
                poly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v52));
                poly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v53));
                poly1.Vertexes.Add(new LwPolylineVertex(v55));
                poly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v56));
                poly1.Vertexes.Add(new LwPolylineVertex(v46));
                poly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.3, contour);
                Line Line53 = new Line(v57, v58);
                Line Line54 = new Line(v59, v60);
                /*//定位孔1
                Vector2[] Line55 = { v61, v62 };
                fun.drawPlinetype(dxf, Line55, refin, Linetype.Dashed);
                Vector2[] Line56 = { v62, v63 };
                fun.drawPlinetype(dxf, Line56, refin, Linetype.Dashed);
                Vector2[] Line57 = { v63, v64 };
                fun.drawPlinetype(dxf, Line57, refin, Linetype.Dashed);
                Vector2[] Line58 = { v64, v65 };
                fun.drawPlinetype(dxf, Line58, refin, Linetype.Dashed);
                Vector2[] Line59 = { v65, v66 };
                fun.drawPlinetype(dxf, Line59, refin, Linetype.Dashed);
                Vector2[] Line60 = { v66, v67 };
                fun.drawPlinetype(dxf, Line60, refin, Linetype.Dashed);
                Vector2[] Line67 = { v62, v66 };
                fun.drawPlinetype(dxf, Line67, refin, Linetype.Dashed);
                Vector2[] Line68 = { v63, v65 };
                fun.drawPlinetype(dxf, Line68, refin, Linetype.Dashed);
                //定位孔2
                Vector2[] Line61 = { v68, v69 };
                fun.drawPlinetype(dxf, Line61, refin, Linetype.Dashed);
                Vector2[] Line62 = { v69, v70 };
                fun.drawPlinetype(dxf, Line62, refin, Linetype.Dashed);
                Vector2[] Line63 = { v70, v71 };
                fun.drawPlinetype(dxf, Line63, refin, Linetype.Dashed);
                Vector2[] Line64 = { v71, v72 };
                fun.drawPlinetype(dxf, Line64, refin, Linetype.Dashed);
                Vector2[] Line65 = { v72, v73 };
                fun.drawPlinetype(dxf, Line65, refin, Linetype.Dashed);
                Vector2[] Line66 = { v73, v74 };
                fun.drawPlinetype(dxf, Line66, refin, Linetype.Dashed);
                Vector2[] Line69 = { v70, v72 };
                fun.drawPlinetype(dxf, Line69, refin, Linetype.Dashed);
                Vector2[] Line70 = { v69, v73 };
                fun.drawPlinetype(dxf, Line70, refin, Linetype.Dashed);*/
                //柄方图层
                Line53.Layer = centre;
                Line54.Layer = centre;
                Line53.Linetype = Linetype.Center;
                Line54.Linetype = Linetype.Center;
                //柄方
                dxf.AddEntity(Line53);
                dxf.AddEntity(Line54);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 1;
                dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 2.5;
                double offset = 20;
                //线段尺寸标注
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v3, v16), -(v3.X - v2.X) - offset, 270, dimensionStyle);
                dim2.UserText = "TD = " + Math.Round(td / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                double toh = Convert.ToDouble(data["thltctrh"]);
                double tol = Convert.ToDouble(data["thltctrl"]);
                if (toh == 0 && tol == 0)
                {
                    LinearDimension dim3 = new LinearDimension(new Line(v17, v15), -offset * 1 / 2, 0, dimensionStyle);
                    dim3.UserText = "THL = " + Math.Round(thl / scale, 2);
                    dxf.AddEntity(dim3);
                }
                else
                {
                    fun.dimrot(dxf, v17, v15, 0, -offset * 1 / 2, 2.5, 2, 2.5, "THL = " + Math.Round(thl / scale, 2), toh + "", tol + "");
                }


                string l5;
                string kr;

                if (mc == 0) { l5 = "8P"; kr = "4°30′"; }
                else if (mc == 1) { l5 = "4P"; kr = "8°30′"; }
                else if (mc == 2) { l5 = "2P"; kr = "17°"; }
                else if (mc == 3) { l5 = "6P"; kr = "6°"; }
                else { l5 = ""; kr = ""; }

                if (mc == 3 && tp > 2.5)
                {
                    Line line01 = new Line(fun.Polar(v80, pi, 4), fun.Polar(v81, pi, 4)); fun.drawBline(dxf, line01, 0.3, contour);
                }
                if (mc == 1 && tp > 2.5)
                {
                    Line line01 = new Line(fun.Polar(v80, pi, 4), fun.Polar(v81, pi, 4)); fun.drawBline(dxf, line01, 0.3, contour);
                    Line line02 = new Line(fun.Polar(v80, pi, 6.5), fun.Polar(v81, pi, 6.5)); fun.drawBline(dxf, line02, 0.3, contour);
                }


                LinearDimension dim00 = new LinearDimension(new Line(v3, v2), offset, 0, dimensionStyle);
                dim00.UserText = "TCL = " + l5;
                dxf.AddEntity(dim00);

                fun.jdbz2(dxf, new Line(v3, v4), new Line(v2, v3), offset, 2.5, 2, 0.6, "KAPR=" + kr, "", "");
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v17, v13), -offset - 5, 0, dimensionStyle);
                dim4.UserText = "LU = " + Math.Round(lu / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                double toh1 = Convert.ToDouble(data["oaltctrh"]);
                double tol1 = Convert.ToDouble(data["oaltctrl"]);
                string oaltctr = Convert.ToString(data["oaltctr"]);
                if (toh1 == 0 && tol1 == 0)
                {
                    if (oaltctr.Equals("0"))
                    {
                        LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 2, 0, dimensionStyle);
                        dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                        dxf.AddEntity(dim5);
                    }
                    else
                    {
                        LinearDimension dim7 = new LinearDimension(new Line(v17, v10), -offset * 2, 0, dimensionStyle);
                        dim7.UserText = "OAL = " + Math.Round(oal / scale, 2) + "  " + oaltctr;
                        dxf.AddEntity(dim7);
                    }


                }
                else
                {
                    fun.dimrot(dxf, v17, v10, 0, -offset * 2, 2.5, 2, 2.5, "OAL = " + Math.Round(oal / scale, 2), toh1 + "", tol1 + "");
                }


                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v23, v26), -offset - (v26.Y - v11.Y), 0, dimensionStyle);
                dim6.UserText = "DRVL = " + Math.Round(drvl / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                string tcdconws = Convert.ToString(data["tcdconws"]);
                if (tcdconws.Equals("0"))
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                    dim7.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                    dxf.AddEntity(dim7);
                }
                else
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                    dim7.UserText = "DMM = " + Math.Round(dmm / scale, 2) + "  " + tcdconws;
                    dxf.AddEntity(dim7);
                }


                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v46, v50), -offset, 135, dimensionStyle);
                dim8.UserText = "DRVSC = " + Math.Round(drvsc / scale, 2);
                dxf.AddEntity(dim8);
                //填充柄方
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
                hatchpoly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
                hatchpoly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
                hatchpoly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
                hatchpoly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 89, 5, hline1, harc1, hatching);
                /*
                //填充螺旋槽
                LwPolyline hatchpoly2 = new LwPolyline();
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
                hatchpoly2.IsClosed = true;
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)hatchpoly2.Explode()[i];
                    }
                }
                var x = lu / 5.00 * Math.Tan(FHA * pi / 180);
                if (x < tcpd / 2.00)
                {
                    fun.hatchsuboflinew(dxf, htype2, hnumst2, -FHA, lu / 2.00 * 8 * Math.Sin(FHA * pi / 180), hline2, contour, 0.3);
                }
                else
                {
                    fun.hatchsuboflinew(dxf, htype2, hnumst2, -FHA, lu / 5.00 * 8 * Math.Sin(FHA * pi / 180), hline2, contour, 0.3);
                }
                */
                double lxxx = Convert.ToDouble(data["lxxx"]);
                if (lxxx == 0)
                {
                    Vector2 v01 = fun.Polar(v17, 90 * pi / 180, tcpd / 4);
                    Vector2 v02p = fun.Polar(v01, -FHA * pi / 180, 10);
                    Vector2 v02 = fun.Inters(v01, v02p, v15, v16);
                    Vector2 v03 = fun.Polar(v17, 90 * pi / 180, tcpd / 6 * 4);
                    Vector2 v04p = fun.Polar(v03, -FHA * pi / 180, 10);
                    Vector2 v04;
                    if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v03.Y - v15.Y)) * 180 / pi)
                    {
                        v04 = fun.Inters(v03, v04p, v4, v15);
                    }
                    else
                    {
                        v04 = fun.Inters(v03, v04p, v15, v16);
                    }

                    Vector2 v05 = new Vector2(v2.X, v2.Y);
                    Vector2 v06p = fun.Polar(v05, -FHA * pi / 180, 10);
                    Vector2 v06;
                    if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v05.Y - v15.Y)) * 180 / pi)
                    {
                        v06 = fun.Inters(v05, v06p, v4, v15);
                    }
                    else
                    {
                        v06 = fun.Inters(v05, v06p, v15, v16);
                    }
                    Vector2 v07p = fun.Polar(v05, 90 * pi / 180, (v03.Y - v01.Y));
                    Vector2 v08p = fun.Polar(v07p, -FHA * pi / 180, 10);
                    Vector2 v07 = fun.Inters(v07p, v08p, v3, v4);
                    Vector2 v08;
                    if (FHA <= 90 - Math.Atan((v15.X - v07.X) / (v07.Y - v15.Y)) * 180 / pi)
                    {
                        v08 = fun.Inters(v07, v08p, v4, v15);
                    }
                    else
                    {
                        v08 = fun.Inters(v07, v08p, v15, v16);
                    }




                    Vector2[] Line01 = { v4, v15 };
                    //fun.drawBLine(dxf, Line01, 0.3, contour);
                    Line line01 = new Line(v01, v02);
                    line01.Lineweight = Lineweight.W25;
                    line01.Layer = additionalline;
                    dxf.AddEntity(line01);
                    Line line02 = new Line(v03, v04);
                    line02.Lineweight = Lineweight.W25;
                    line02.Layer = additionalline;
                    dxf.AddEntity(line02);
                    Line line03 = new Line(v05, v06);
                    line03.Lineweight = Lineweight.W25;
                    line03.Layer = additionalline;
                    dxf.AddEntity(line03);
                    Line line04 = new Line(v07, v08);
                    line04.Lineweight = Lineweight.W25;
                    line04.Layer = additionalline;
                    dxf.AddEntity(line04);


                    LwPolyline hatchpoly01 = new LwPolyline();
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v01));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v17));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v16));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v02));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v01));
                    hatchpoly01.IsClosed = true;
                    String[] htype01 = new String[100];
                    Line[] hline01 = new Line[100];
                    Arc[] harc01 = new Arc[100];
                    int hnumst01 = hatchpoly01.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst01; i++)
                    {
                        htype01[i] = hatchpoly01.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype01[i] == "Line")
                        {
                            hline01[i] = (Line)hatchpoly01.Explode()[i];
                        }
                        if (htype01[i] == "Arc")
                        {
                            harc01[i] = (Arc)hatchpoly01.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype01, hnumst01, 89, 5 * scale, hline01, harc01, hatching);





                    LwPolyline hatchpoly02 = new LwPolyline();
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v03));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v04));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v15));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v06));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v05));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v03));
                    hatchpoly02.IsClosed = true;
                    String[] htype02 = new String[102];
                    Line[] hline02 = new Line[102];
                    Arc[] harc02 = new Arc[102];
                    int hnumst02 = hatchpoly02.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst02; i++)
                    {
                        htype02[i] = hatchpoly02.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype02[i] == "Line")
                        {
                            hline02[i] = (Line)hatchpoly02.Explode()[i];
                        }
                        if (htype02[i] == "Arc")
                        {
                            harc02[i] = (Arc)hatchpoly02.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype02, hnumst02, 89, 5 * scale, hline02, harc02, hatching);


                    LwPolyline hatchpoly03 = new LwPolyline();
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v07));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v08));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v15));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v4));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v07));
                    hatchpoly03.IsClosed = true;
                    String[] htype03 = new String[103];
                    Line[] hline03 = new Line[103];
                    Arc[] harc03 = new Arc[103];
                    int hnumst03 = hatchpoly03.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst03; i++)
                    {
                        htype03[i] = hatchpoly03.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype03[i] == "Line")
                        {
                            hline03[i] = (Line)hatchpoly03.Explode()[i];
                        }
                        if (htype03[i] == "Arc")
                        {
                            harc03[i] = (Arc)hatchpoly03.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype03, hnumst03, 89, 5 * scale, hline03, harc03, hatching);

                    Angular2LineDimension angdim2 = new Angular2LineDimension(new Line(v05, v06), new Line(v41, v42), offset * 4, dimensionStyle);
                    angdim2.UserText = "FHA = " + FHA + "°";
                    dxf.AddEntity(angdim2);
                    //fun.jdbz2(dxf, new Line(v41, v42), new Line(v05, v06), offset * 5, 2.5, 0.8, 0.4, "FHA = " + FHA + "°", "", "");

                }
                else
                {
                    Vector2 v01 = fun.Polar(v17, 90 * pi / 180, tcpd / 4);
                    Vector2 v02p = fun.Polar(v01, -FHA * pi / 180, 10);
                    Vector2 v02 = fun.Inters(v01, v02p, v15, v16);
                    Vector2 v03 = fun.Polar(v17, 90 * pi / 180, tcpd / 6 * 4);
                    Vector2 v04p = fun.Polar(v03, -FHA * pi / 180, 10);
                    Vector2 v04;
                    if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v03.Y - v15.Y)) * 180 / pi)
                    {
                        v04 = fun.Inters(v03, v04p, v4, v15);
                    }
                    else
                    {
                        v04 = fun.Inters(v03, v04p, v15, v16);
                    }

                    Vector2 v05 = new Vector2(v2.X, v2.Y);
                    Vector2 v06p = fun.Polar(v05, -FHA * pi / 180, 10);
                    Vector2 v06;
                    if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v05.Y - v15.Y)) * 180 / pi)
                    {
                        v06 = fun.Inters(v05, v06p, v4, v15);
                    }
                    else
                    {
                        v06 = fun.Inters(v05, v06p, v15, v16);
                    }
                    Vector2 v07p = fun.Polar(v05, 90 * pi / 180, (v03.Y - v01.Y));
                    Vector2 v08p = fun.Polar(v07p, -FHA * pi / 180, 10);
                    Vector2 v07 = fun.Inters(v07p, v08p, v3, v4);
                    Vector2 v08;
                    if (FHA <= 90 - Math.Atan((v15.X - v07.X) / (v07.Y - v15.Y)) * 180 / pi)
                    {
                        v08 = fun.Inters(v07, v08p, v4, v15);
                    }
                    else
                    {
                        v08 = fun.Inters(v07, v08p, v15, v16);
                    }

                    Vector2 a1 = new Vector2(v01.X, -v01.Y);
                    Vector2 a2 = new Vector2(v02.X, -v02.Y);
                    Vector2 a3 = new Vector2(v03.X, -v03.Y);
                    Vector2 a4 = new Vector2(v04.X, -v04.Y);
                    Vector2 a5 = new Vector2(v05.X, -v05.Y);
                    Vector2 a6 = new Vector2(v06.X, -v06.Y);
                    Vector2 a7 = new Vector2(v07.X, -v07.Y);
                    Vector2 a8 = new Vector2(v08.X, -v08.Y);



                    Vector2[] Line01 = { v4, v15 };
                    fun.drawBLine(dxf, Line01, 0.3, contour);
                    Line line01 = new Line(a1, a2);
                    line01.Lineweight = Lineweight.W25;
                    line01.Layer = additionalline;
                    dxf.AddEntity(line01);
                    Line line02 = new Line(a3, a4);
                    line02.Lineweight = Lineweight.W25;
                    line02.Layer = additionalline;
                    dxf.AddEntity(line02);
                    Line line03 = new Line(a5, a6);
                    line03.Lineweight = Lineweight.W25;
                    line03.Layer = additionalline;
                    dxf.AddEntity(line03);
                    Line line04 = new Line(a7, a8);
                    line04.Lineweight = Lineweight.W25;
                    line04.Layer = additionalline;
                    dxf.AddEntity(line04);



                    LwPolyline hatchpoly01 = new LwPolyline();
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(a1));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v2));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v3));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(a2));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(a1));
                    hatchpoly01.IsClosed = true;
                    String[] htype01 = new String[100];
                    Line[] hline01 = new Line[100];
                    Arc[] harc01 = new Arc[100];
                    int hnumst01 = hatchpoly01.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst01; i++)
                    {
                        htype01[i] = hatchpoly01.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype01[i] == "Line")
                        {
                            hline01[i] = (Line)hatchpoly01.Explode()[i];
                        }
                        if (htype01[i] == "Arc")
                        {
                            harc01[i] = (Arc)hatchpoly01.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype01, hnumst01, 89, 5 * scale, hline01, harc01, hatching);





                    LwPolyline hatchpoly02 = new LwPolyline();
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(a3));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(a4));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v4));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(a6));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(a5));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(a3));
                    hatchpoly02.IsClosed = true;
                    String[] htype02 = new String[102];
                    Line[] hline02 = new Line[102];
                    Arc[] harc02 = new Arc[102];
                    int hnumst02 = hatchpoly02.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst02; i++)
                    {
                        htype02[i] = hatchpoly02.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype02[i] == "Line")
                        {
                            hline02[i] = (Line)hatchpoly02.Explode()[i];
                        }
                        if (htype02[i] == "Arc")
                        {
                            harc02[i] = (Arc)hatchpoly02.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype02, hnumst02, 89, 5 * scale, hline02, harc02, hatching);


                    LwPolyline hatchpoly03 = new LwPolyline();
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(a7));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(a8));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v4));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v15));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(a7));
                    hatchpoly03.IsClosed = true;
                    String[] htype03 = new String[103];
                    Line[] hline03 = new Line[103];
                    Arc[] harc03 = new Arc[103];
                    int hnumst03 = hatchpoly03.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst03; i++)
                    {
                        htype03[i] = hatchpoly03.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype03[i] == "Line")
                        {
                            hline03[i] = (Line)hatchpoly03.Explode()[i];
                        }
                        if (htype03[i] == "Arc")
                        {
                            harc03[i] = (Arc)hatchpoly03.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype03, hnumst03, 89, 5 * scale, hline03, harc03, hatching);


                    Angular2LineDimension angdim2 = new Angular2LineDimension(new Line(a5, a6), new Line(v41, v42), offset * 5, dimensionStyle);
                    angdim2.UserText = "FHA = " + FHA + "°";
                    dxf.AddEntity(angdim2);

                    //fun.jdbz2(dxf, new Line(v41, v42), new Line(a5, a6), offset * 5, 2.5, 0.8, 0.4, "FHA = " + FHA + "°", "", "");

                }

                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v2.X - 210 + (v45.X + v8.Y - v2.X) / 2.00, 148.5), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (fdc == 2)
            {
                double soal = Convert.ToDouble(data["oal"]);
                double scale = Convert.ToDouble(data["scale"]); //放大系数
                if (scale == 0 && soal < 105)
                {
                    scale = 2.0;
                }
                else if (scale == 0 && soal < 210)
                {
                    scale = 1.0;
                }
                else if (scale == 0)
                {
                    scale = 0.5;
                }
                double pi = Math.PI;
                double td = Convert.ToDouble(data["td"]) * scale;
                double dmm = Convert.ToDouble(data["dmm"]) * scale;
                double tp = Convert.ToDouble(data["tp"]) * scale;
                double dn = Convert.ToDouble(data["dn"]) * scale;
                if (dn == 0)
                {
                    dn = td - 1.1325 * tp - 0.15;
                }
                double mc = Convert.ToDouble(data["mc"]);
                double qxzj;
                if (mc == 0)
                {
                    qxzj = 4.5 * pi / 180;
                }
                if (mc == 1)
                {
                    qxzj = 8.5 * pi / 180;
                }
                if (mc == 2)
                {
                    qxzj = 17 * pi / 180;
                }
                else
                {
                    qxzj = 6 * pi / 180;
                }

                double tcl;
                if (mc == 0)
                {
                    tcl = 8 * tp;
                }
                else if (mc == 1)
                {
                    tcl = 4 * tp;
                }
                else if (mc == 2)
                {
                    tcl = 2 * tp;
                }
                else
                {
                    tcl = 6 * tp;
                }

                if (tcl == 0)
                {
                    tcl = tp * 2.3;
                }
                double tcpd = td - tcl * Math.Tan(qxzj);
                double thl = Convert.ToDouble(data["thl"]) * scale;
                double lu = Convert.ToDouble(data["lu"]) * scale;
                if (lu == 0)
                {
                    lu = thl * 39 / 22;
                }
                double oal = Convert.ToDouble(data["oal"]) * scale;
                double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
                double drvl = Convert.ToDouble(data["drvl"]) * scale;
                /*double d7 = 2.1 * scale;
                double d8 = 1 * scale;
                double d9 = 2.5 * scale;
                double d10 = 1.2 * scale;
                double l4 = 2.6 * scale;*/
                double ds = dmm - 0.08 * scale;//柄方外圆
                double isframe = Convert.ToDouble(data["isframe"]);
                //坐标
                //主视图
                Vector2 v2 = new Vector2(-oal / 2.00, tcpd / 2.00);
                Vector2 v3 = new Vector2(v2.X + tcl, td / 2.00);
                Vector2 v4 = new Vector2(v2.X + thl, v3.Y);
                Vector2 v5 = new Vector2((td - dn) / 2.00 + v4.X, dn / 2.00);
                Vector2 v6 = new Vector2(v2.X + lu, v5.Y);
                Vector2 v7 = new Vector2(v6.X, dmm / 2.00);
                Vector2 v8 = new Vector2(v2.X + oal - 0.15 * dmm, ds / 2);
                Vector2 v9 = new Vector2(v2.X + oal, 0.35 * dmm);
                Vector2 v10 = new Vector2(v9.X, -v9.Y);
                Vector2 v11 = new Vector2(v8.X, -v8.Y);
                Vector2 v12 = new Vector2(v7.X, -v7.Y);
                Vector2 v13 = new Vector2(v6.X, -v6.Y);
                Vector2 v14 = new Vector2(v5.X, -v5.Y);
                Vector2 v15 = new Vector2(v4.X, -v4.Y);
                Vector2 v16 = new Vector2(v3.X, -v3.Y);
                Vector2 v17 = new Vector2(v2.X, -v2.Y);
                Vector2 v19 = new Vector2(v8.X - drvl, ds / 2.00 * (Math.Sin(45 * pi / 180) * drvsc / ds - Math.Cos(45 * pi / 180) * Math.Sqrt(1 - (drvsc * drvsc) / (ds * ds))));
                Vector2 v18 = new Vector2(v19.X, drvsc * Math.Sin(45 * pi / 180) - v19.Y);
                Vector2 v20 = new Vector2(v8.X, v19.Y);
                Vector2 v21 = new Vector2(v20.X, v18.Y);
                Vector2 v22 = new Vector2(v21.X - (v18.Y - v19.Y) / 2.00 * Math.Tan(60 * pi / 180), (v18.Y + v19.Y) / 2.00);
                Vector2 v23 = new Vector2(v18.X, -v18.Y);
                Vector2 v24 = new Vector2(v19.X, -v19.Y);
                Vector2 v25 = new Vector2(v20.X, -v20.Y);
                Vector2 v26 = new Vector2(v21.X, -v21.Y);
                Vector2 v27 = new Vector2(v22.X, -v22.Y);
                Vector2 v41 = new Vector2(v2.X - 2, 0);
                Vector2 v42 = new Vector2(v9.X + 2, 0);
                Vector2 v80 = new Vector2(v8.X - drvl - 1 * scale, v7.Y);
                Vector2 v81 = new Vector2(v80.X, -v80.Y);
                Vector2 v82 = new Vector2(v80.X, ds / 2.00);
                Vector2 v83 = new Vector2(v82.X, -v82.Y);
                //螺尖槽
                Vector2 v87 = new Vector2(v2.X + tcpd * 5 / 36, v2.Y);
                Vector2 v88 = new Vector2(v2.X + tcl + thl / 5, v87.Y - 5 * tcpd / 18);
                Vector2 v86 = new Vector2(v87.X, v87.Y - 5 * tcpd / 9);
                Vector2 v89 = new Vector2(v87.X, v87.Y + (v87.X - v2.X) * (td - tcpd) / 2 / tcl);
                Vector2 v84 = new Vector2(v87.X, -v89.Y);
                Vector2 v85 = new Vector2(v86.X + (-v88.Y - v84.Y) * (td - tcpd) / 2 / tcl, -v88.Y);
                Vector2 v90 = new Vector2((v87.X - v88.X) * v88.Y * v88.Y / (v87.Y - v88.Y) / (v87.Y - v88.Y) + v88.X, 0);
                Vector2 v91 = new Vector2(v90.X, v88.Y * 2 - v90.Y);
                Vector2 v93 = new Vector2(v88.X, v15.Y);
                double cl = Math.Sqrt((v85.Y - v84.Y) * (v85.Y - v84.Y) + (v85.X - v84.X) * (v85.X - v84.X)) / 2;
                double sr = Math.Sqrt(cl * cl + (cl * (td - tcpd) / 2 / tcl) * (cl * (td - tcpd) / 2 / tcl));
                double h = sr - (td - tcpd) * cl / 2 / tcl;
                Vector2 v94 = new Vector2(v85.X, v85.Y - sr);
                Vector2 v92 = new Vector2(v87.X, Math.Sqrt(sr * sr - (v85.X - v86.X) * (v85.X - v86.X)) + v94.Y);
                //排屑槽
                Vector2 v95 = new Vector2(v2.X + lu - 3, v88.Y);
                double cr = (v5.Y - v88.Y) * 2;
                Vector2 v96 = new Vector2(v95.X - cr * Math.Sin(60 * pi / 180), v5.Y);
                Vector2 v97 = new Vector2(v95.X, -v95.Y);
                Vector2 v98 = new Vector2(v96.X, -v96.Y);
                //柄方
                Vector2 v45 = new Vector2(105 + oal / 4.00, v8.Y - (v20.Y - v25.Y) * Math.Cos(45 * pi / 180));
                Vector2 v46 = new Vector2(v45.X - (v20.Y - v25.Y) / 2.00, v45.Y + (v20.Y - v25.Y) / 2.00);
                Vector2 v47 = new Vector2(v45.X * 2 - v46.X, v46.Y);
                Vector2 v48 = new Vector2(v45.X + v45.Y, 0);
                Vector2 v49 = new Vector2(v45.X + v46.Y, v48.Y + v47.X - v45.X);
                Vector2 v50 = new Vector2(v49.X, -v49.Y);
                Vector2 v51 = new Vector2(v45.X, -v45.Y);
                Vector2 v52 = new Vector2(v47.X, -v47.Y);
                Vector2 v53 = new Vector2(v46.X, -v46.Y);
                Vector2 v54 = new Vector2(v45.X * 2 - v48.X, v48.Y);
                Vector2 v55 = new Vector2(v45.X * 2 - v50.X, v50.Y);
                Vector2 v56 = new Vector2(v45.X * 2 - v49.X, v49.Y);
                Vector2 v57 = new Vector2(v45.X - ds / 2.00 - 2, 0);
                Vector2 v58 = new Vector2(v45.X + ds / 2.00 + 2, 0);
                Vector2 v59 = new Vector2(v45.X, ds / 2.00 + 2);
                Vector2 v60 = new Vector2(v59.X, -v59.Y);
                string tctr = Convert.ToString(data["tctr"]);
                if (!tctr.Equals("0"))
                {
                    Vector2 a1 = fun.Polar(v3, fun.CalAngle(v3, v4), fun.CalDistance(v3, v4) / 2);
                    Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                    Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                    Line line101 = new Line(a1, a2);
                    dxf.AddEntity(line101);
                    fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

                }
                /*//定位孔1
                Vector2 v65 = new Vector2(v2.X, d7 / 2.00);
                Vector2 v66 = new Vector2((d7 - d8) / 2.00 * Math.Tan(60 * pi / 180) + v65.X, d8 / 2.00);
                Vector2 v67 = new Vector2(v65.X + l4, v66.Y);
                Vector2 v68 = new Vector2(d8 / 2.00 / Math.Tan(60 * pi / 180) + v67.X, 0);
                Vector2 v69 = new Vector2(v67.X, -v67.Y);
                Vector2 v70 = new Vector2(v66.X, -v66.Y);
                Vector2 v71 = new Vector2(v65.X, -v65.Y);
                //定位孔2
                Vector2 v72 = new Vector2(v9.X, d9 / 2.00);
                Vector2 v73 = new Vector2(v72.X - (d9 - d10) / 2.00 * Math.Tan(60 * pi / 180), d10 / 2.00);
                Vector2 v74 = new Vector2(v72.X - l4, v73.Y);
                Vector2 v75 = new Vector2(v74.X - d10 / 2.00 / Math.Tan(60 * pi / 180), 0);
                Vector2 v76 = new Vector2(v74.X, -v74.Y);
                Vector2 v77 = new Vector2(v73.X, -v73.Y);
                Vector2 v78 = new Vector2(v72.X, -v72.Y);*/
                //线段
                double dx = v2.X;
                if (tcpd < dn)
                {
                    dx = (v5.Y - oal * (td - tcpd) / 4 / tcl - tcpd / 2) * 2 * tcl / (td - tcpd);
                }
                Vector2 v35 = new Vector2(dx, v5.Y);
                Vector2 v36 = new Vector2(dx, v14.Y);
                Line line34 = new Line(v5, v35);
                line34.Lineweight = Lineweight.W25;
                line34.Layer = additionalline;
                dxf.AddEntity(line34);
                Line line35 = new Line(v14, v36);
                line35.Lineweight = Lineweight.W25;
                line35.Layer = additionalline;
                dxf.AddEntity(line35);
                //主视图
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v80 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v81, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line18 = { v2, v17 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line23 = { v6, v13 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v7, v12 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v8, v21 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v20, v25 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v26, v11 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v21, v18 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v18, v19 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v19, v20 };
                fun.drawBLine(dxf, Line30, 0.3, contour);
                Vector2[] Line31 = { v25, v24 };
                fun.drawBLine(dxf, Line31, 0.3, contour);
                Vector2[] Line32 = { v24, v23 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v23, v26 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                //Arc Arc1 = new Arc(v22, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
                //Arc Arc2 = new Arc(v27, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v21));
                Arc1.Vertexes.Add(new LwPolylineVertex(v20));
                Arc1.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v25));
                Arc2.Vertexes.Add(new LwPolylineVertex(v26));
                Arc2.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                LwPolyline Arc4 = new LwPolyline();
                Arc4.Vertexes.Add(new LwPolylineVertex(v18));
                Arc4.Vertexes.Add(new LwPolylineVertex(v19));
                Arc4.Vertexes[0].Bulge = 1 * scale / ((v18.Y - v19.Y) / 2.00);
                fun.PolyFill(dxf, Arc4, 0.3, contour);
                LwPolyline Arc5 = new LwPolyline();
                Arc5.Vertexes.Add(new LwPolylineVertex(v24));
                Arc5.Vertexes.Add(new LwPolylineVertex(v23));
                Arc5.Vertexes[0].Bulge = 1 * scale / ((v24.Y - v23.Y) / 2.00);
                fun.PolyFill(dxf, Arc5, 0.3, contour);
                Vector2[] Line38 = { v41, v42 };
                fun.drawPlinetype(dxf, Line38, 0.15, centre, Linetype.Center);
                Vector2[] Line39 = { v18, v20 };
                fun.drawBLine(dxf, Line39, 0.15, contour);
                Vector2[] Line40 = { v19, v21 };
                fun.drawBLine(dxf, Line40, 0.15, contour);
                Vector2[] Line41 = { v24, v26 };
                fun.drawBLine(dxf, Line41, 0.15, contour);
                Vector2[] Line42 = { v23, v25 };
                fun.drawBLine(dxf, Line42, 0.15, contour);
                Vector2[] Line55 = { v80, v81 };
                fun.drawBLine(dxf, Line55, 0.3, contour);
                Vector2[] Line56 = { v82, v8 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v83, v11 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                Line Line58 = new Line(v89, v87);
                LwPolyline Arc3 = new LwPolyline();
                Arc3.Vertexes.Add(new LwPolylineVertex(v87));
                Arc3.Vertexes.Add(new LwPolylineVertex(v86));
                Arc3.Vertexes[0].Bulge = (v87.X - v2.X) / (v87.Y - v86.Y) * 2;
                //fun.PolyFill(dxf, Arc3, 0.1, contour);
                Arc3.Layer = contour;
                dxf.AddEntity(Arc3);
                List<Vector3> point1 = new List<Vector3>
            {
                fun.Tothree(v86),
                fun.Tothree(v90),
                fun.Tothree(v88),
                fun.Tothree(v91),
                fun.Tothree(v87),
            };
                Spline spline1 = new Spline(point1);
                spline1.Layer = contour;
                dxf.AddEntity(spline1);
                Line Line59 = new Line(v86, v92);
                LwPolyline Arc6 = new LwPolyline();
                Arc6.Vertexes.Add(new LwPolylineVertex(v85));
                Arc6.Vertexes.Add(new LwPolylineVertex(v84));
                Arc6.Vertexes[0].Bulge = h / cl;
                Arc6.Layer = contour;
                dxf.AddEntity(Arc6);
                Line Line60 = new Line(v85, v93);
                LwPolyline Arc7 = new LwPolyline();
                Arc7.Vertexes.Add(new LwPolylineVertex(v95));
                Arc7.Vertexes.Add(new LwPolylineVertex(v96));
                Arc7.Vertexes[0].Bulge = cr * (1 - Math.Sin(60 * pi / 180)) / (cr / 2);
                Arc7.Layer = contour;
                dxf.AddEntity(Arc7);
                Line Line61 = new Line(v88, v95);
                LwPolyline Arc8 = new LwPolyline();
                Arc8.Vertexes.Add(new LwPolylineVertex(v98));
                Arc8.Vertexes.Add(new LwPolylineVertex(v97));
                Arc8.Vertexes[0].Bulge = cr * (1 - Math.Sin(60 * pi / 180)) / (cr / 2);
                Arc8.Layer = contour;
                dxf.AddEntity(Arc8);
                Line Line62 = new Line(v85, v97);
                Vector2[] Line63 = { new Vector2(v4.X, v95.Y), new Vector2(v4.X, v97.Y) };
                fun.drawBLine(dxf, Line63, 0.3, contour);
                Vector2[] Line64 = { new Vector2(v5.X, v95.Y), new Vector2(v5.X, v97.Y) };
                fun.drawBLine(dxf, Line64, 0.3, contour);
                //柄方
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v47));
                poly1.Vertexes.Add(new LwPolylineVertex(v49));
                poly1.Vertexes.Add(new LwPolylineVertex(v50));
                poly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v52));
                poly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v53));
                poly1.Vertexes.Add(new LwPolylineVertex(v55));
                poly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v56));
                poly1.Vertexes.Add(new LwPolylineVertex(v46));
                poly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.3, contour);
                Line Line53 = new Line(v57, v58);
                Line Line54 = new Line(v59, v60);
                /*//定位孔1
                Vector2[] Line55 = { v65, v66 };
                fun.drawPlinetype(dxf, Line55, refin, Linetype.Dashed);
                Vector2[] Line56 = { v66, v67 };
                fun.drawPlinetype(dxf, Line56, refin, Linetype.Dashed);
                Vector2[] Line57 = { v67, v68 };
                fun.drawPlinetype(dxf, Line57, refin, Linetype.Dashed);
                Vector2[] Line58 = { v68, v69 };
                fun.drawPlinetype(dxf, Line58, refin, Linetype.Dashed);
                Vector2[] Line59 = { v69, v70 };
                fun.drawPlinetype(dxf, Line59, refin, Linetype.Dashed);
                Vector2[] Line60 = { v70, v71 };
                fun.drawPlinetype(dxf, Line60, refin, Linetype.Dashed);
                Vector2[] Line67 = { v66, v70 };
                fun.drawPlinetype(dxf, Line67, refin, Linetype.Dashed);
                Vector2[] Line68 = { v67, v69 };
                fun.drawPlinetype(dxf, Line68, refin, Linetype.Dashed);
                //定位孔2
                Vector2[] Line61 = { v72, v73 };
                fun.drawPlinetype(dxf, Line61, refin, Linetype.Dashed);
                Vector2[] Line62 = { v73, v74 };
                fun.drawPlinetype(dxf, Line62, refin, Linetype.Dashed);
                Vector2[] Line63 = { v74, v75 };
                fun.drawPlinetype(dxf, Line63, refin, Linetype.Dashed);
                Vector2[] Line64 = { v75, v76 };
                fun.drawPlinetype(dxf, Line64, refin, Linetype.Dashed);
                Vector2[] Line65 = { v76, v77 };
                fun.drawPlinetype(dxf, Line65, refin, Linetype.Dashed);
                Vector2[] Line66 = { v77, v78 };
                fun.drawPlinetype(dxf, Line66, refin, Linetype.Dashed);
                Vector2[] Line69 = { v74, v76 };
                fun.drawPlinetype(dxf, Line69, refin, Linetype.Dashed);
                Vector2[] Line70 = { v73, v77 };
                fun.drawPlinetype(dxf, Line70, refin, Linetype.Dashed);*/
                //主视图图层
                Line58.Layer = contour;
                Line59.Layer = contour;
                Line60.Layer = contour;
                Line61.Layer = contour;
                Line62.Layer = contour;
                //柄方图层
                Line53.Layer = centre;
                Line54.Layer = centre;
                Line53.Linetype = Linetype.Center;
                Line54.Linetype = Linetype.Center;
                //主视图
                dxf.AddEntity(Line58);
                dxf.AddEntity(Line59);
                dxf.AddEntity(Line60);
                dxf.AddEntity(Line61);
                dxf.AddEntity(Line62);
                //柄方
                dxf.AddEntity(Line53);
                dxf.AddEntity(Line54);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 1;
                dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 2.5;
                double offset = 20;
                //线段尺寸标注
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v3, v16), -v3.X + v2.X - offset, 270, dimensionStyle);
                dim2.UserText = "TD = " + Math.Round(td / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                double toh = Convert.ToDouble(data["thltctrh"]);
                double tol = Convert.ToDouble(data["thltctrl"]);
                if (toh == 0 && tol == 0)
                {
                    LinearDimension dim3 = new LinearDimension(new Line(v17, v15), -offset * 1 / 2, 0, dimensionStyle);
                    dim3.UserText = "THL = " + Math.Round(thl / scale, 2);
                    dxf.AddEntity(dim3);
                }
                else
                {
                    fun.dimrot(dxf, v17, v15, 0, -offset * 1 / 2, 2.5, 2, 2.5, "THL = " + Math.Round(thl / scale, 2), toh + "", tol + "");
                }

                string l5;
                string kr;

                if (mc == 0) { l5 = "8P"; kr = "4°30′"; }
                else if (mc == 1) { l5 = "4P"; kr = "8°30′"; }
                else if (mc == 2) { l5 = "2P"; kr = "17°"; }
                else if (mc == 3) { l5 = "6P"; kr = "6°"; }
                else { l5 = ""; kr = ""; }

                if (mc == 3 && tp > 2.5)
                {
                    Line line01 = new Line(fun.Polar(v80, pi, 4), fun.Polar(v81, pi, 4)); fun.drawBline(dxf, line01, 0.3, contour);
                }
                if (mc == 1 && tp > 2.5)
                {
                    Line line01 = new Line(fun.Polar(v80, pi, 4), fun.Polar(v81, pi, 4)); fun.drawBline(dxf, line01, 0.3, contour);
                    Line line02 = new Line(fun.Polar(v80, pi, 6.5), fun.Polar(v81, pi, 6.5)); fun.drawBline(dxf, line02, 0.3, contour);
                }


                LinearDimension dim00 = new LinearDimension(new Line(v3, v2), offset, 0, dimensionStyle);
                dim00.UserText = "TCL = " + l5;
                dxf.AddEntity(dim00);

                fun.jdbz2(dxf, new Line(v3, v4), new Line(v2, v3), offset, 2.5, 2, 0.6, "KAPR=" + kr, "", "");
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v17, v13), -offset - 5, 0, dimensionStyle);
                dim4.UserText = "LU = " + Math.Round(lu / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                double toh1 = Convert.ToDouble(data["oaltctrh"]);
                double tol1 = Convert.ToDouble(data["oaltctrl"]);
                string oaltctr = Convert.ToString(data["oaltctr"]);
                if (toh1 == 0 && tol1 == 0)
                {
                    if (oaltctr.Equals("0"))
                    {
                        LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 2, 0, dimensionStyle);
                        dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                        dxf.AddEntity(dim5);
                    }
                    else
                    {
                        LinearDimension dim7 = new LinearDimension(new Line(v17, v10), -offset * 2, 0, dimensionStyle);
                        dim7.UserText = "OAL = " + Math.Round(oal / scale, 2) + "  " + oaltctr;
                        dxf.AddEntity(dim7);
                    }
                }
                else
                {
                    fun.dimrot(dxf, v17, v10, 0, -offset * 2, 2.5, 2, 2.5, "OAL = " + Math.Round(oal / scale, 2), toh1 + "", tol1 + "");
                }


                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v23, v26), -offset - (v26.Y - v11.Y), 0, dimensionStyle);
                dim6.UserText = "DRVL = " + Math.Round(drvl / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                string tcdconws = Convert.ToString(data["tcdconws"]);
                if (tcdconws.Equals("0"))
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                    dim7.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                    dxf.AddEntity(dim7);
                }
                else
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                    dim7.UserText = "DMM = " + Math.Round(dmm / scale, 2) + "  " + tcdconws;
                    dxf.AddEntity(dim7);
                }


                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v46, v50), -offset, 135, dimensionStyle);
                dim8.UserText = "DRVSC = " + Math.Round(drvsc / scale, 2);
                dxf.AddEntity(dim8);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
                hatchpoly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
                hatchpoly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
                hatchpoly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
                hatchpoly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 89, 5, hline1, harc1, hatching);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v2.X - 210 + (v45.X + v8.Y - v2.X) / 2.00, 148.5), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void RoughShankCuttingTaps(Dictionary<string, Object> data)//粗柄丝锥
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double fdc = Convert.ToDouble(data["fdc"]);
            string path = Convert.ToString(data["path"]);
            string code = Convert.ToString(data["tdz"]);
            // 非空判断
            if (data["lu"].Equals("")) data["lu"] = 0;
            if (data["dn"].Equals("")) data["dn"] = 0;
            if (fdc == 0)
            {
                //作图
                //参数
                double soal = Convert.ToDouble(data["oal"]);
                double scale = Convert.ToDouble(data["scale"]); //放大系数
                if (scale == 0 && soal < 105)
                {
                    scale = 2.0;
                }
                else if (scale == 0 && soal < 210)
                {
                    scale = 1.0;
                }
                else if (scale == 0)
                {
                    scale = 0.5;
                }
                double pi = Math.PI;
                double td = Convert.ToDouble(data["td"]) * scale;
                double dmm = Convert.ToDouble(data["dconms"]) * scale;
                double tp = Convert.ToDouble(data["tp"]) * scale;
                double dn = Convert.ToDouble(data["dn"]) * scale;
                if (dn == 0)
                {
                    dn = td - 1.1325 * tp - 0.15;
                }
                double mc = Convert.ToDouble(data["mc"]);
                double qxzj;
                if (mc == 0)
                {
                    qxzj = 4.5 * pi / 180;
                }
                if (mc == 1)
                {
                    qxzj = 8.5 * pi / 180;
                }
                if (mc == 2)
                {
                    qxzj = 17 * pi / 180;
                }
                else
                {
                    qxzj = 6 * pi / 180;
                }

                double tcl;
                if (mc == 0)
                {
                    tcl = 8 * tp;
                }
                else if (mc == 1)
                {
                    tcl = 4 * tp;
                }
                else if (mc == 2)
                {
                    tcl = 2 * tp;
                }
                else
                {
                    tcl = 6 * tp;
                }

                if (tcl == 0)
                {
                    tcl = tp * 2.3;
                }
                double tcpd = td - tcl * Math.Tan(qxzj);
                double wcf = Convert.ToDouble(data["wcf"]) * scale;
                if (wcf == 0)
                {
                    wcf = td / 3;
                }
                double thl = Convert.ToDouble(data["thl"]) * scale;
                double lu = Convert.ToDouble(data["lu"]) * scale;
                if (lu == 0)
                {
                    lu = thl * 39 / 22;
                }
                double oal = Convert.ToDouble(data["oal"]) * scale;
                double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
                double drvl = Convert.ToDouble(data["drvl"]) * scale;
                double sig = Convert.ToDouble(data["sig"]) * pi / 180;
                double ta = Convert.ToDouble(data["ta"]) * pi / 180;
                double ds = dmm - 0.08 * scale;//柄方外圆
                double ds1 = dmm * 1 / 10.0;
                double isframe = Convert.ToDouble(data["isframe"]);
                //坐标
                //主视图
                Vector2 v2 = new Vector2(-oal / 2.00, tcpd / 2.00);
                Vector2 v1 = new Vector2(v2.X - v2.Y / Math.Tan(sig / 2.00), 0);
                Vector2 v3 = new Vector2(v2.X + tcl, td / 2.00);
                Vector2 v4 = new Vector2(v2.X + thl, v3.Y);
                Vector2 v5 = new Vector2((td - dn) / 2.00 + v4.X, dn / 2.00);
                Vector2 v6 = new Vector2(v2.X + lu, v5.Y);
                Vector2 p7_1 = fun.Polar(v1, pi / 2, dmm / 2.0);
                Vector2 p7_2 = fun.Polar(p7_1, 0, oal);
                Vector2 v7;
                if (v6.Y == dmm / 2.0)
                {
                    v7 = v6;
                }
                else if (v6.Y < dmm / 2.0)
                {
                    v7 = fun.Inters(p7_1, p7_2, v6, fun.Polar(v6, pi / 4, oal));
                }
                else
                {
                    v7 = fun.Inters(p7_1, p7_2, v6, fun.Polar(v6, pi / -4, oal));
                }
                //Vector2 v7 = new Vector2((dmm - dn) / 2.00 / Math.Tan(ta) + v6.X, dmm / 2.00);
                Vector2 v8 = new Vector2(v2.X + oal - 0.15 * dmm, ds / 2);
                Vector2 v9 = new Vector2(v2.X + oal, 0.35 * dmm);
                Vector2 v10 = new Vector2(v9.X, -v9.Y);
                Vector2 v11 = new Vector2(v8.X, -v8.Y);
                Vector2 v12 = new Vector2(v7.X, -v7.Y);
                Vector2 v13 = new Vector2(v6.X, -v6.Y);
                Vector2 v14 = new Vector2(v5.X, -v5.Y);
                Vector2 v15 = new Vector2(v4.X, -v4.Y);
                Vector2 v16 = new Vector2(v3.X, -v3.Y);
                Vector2 v17 = new Vector2(v2.X, -v2.Y);
                Vector2 v19 = new Vector2(v8.X - drvl, ds1);
                Vector2 v18 = fun.Inters(v7, v8, v19, fun.Polar(v19, pi / 2, 150));
                Vector2 v20 = new Vector2(v8.X, v19.Y);
                Vector2 v21 = new Vector2(v20.X, v18.Y);
                Vector2 v22 = new Vector2(v21.X - (v18.Y - v19.Y) / 2.00 * Math.Tan(60 * pi / 180), (v18.Y + v19.Y) / 2.00);
                Vector2 v23 = new Vector2(v18.X, -v18.Y);
                Vector2 v24 = new Vector2(v19.X, -v19.Y);
                Vector2 v25 = new Vector2(v20.X, -v20.Y);
                Vector2 v26 = new Vector2(v21.X, -v21.Y);
                Vector2 v27 = new Vector2(v22.X, -v22.Y);
                Vector2 v28 = new Vector2(v2.X + lu - 3, 0);
                Vector2 v29 = new Vector2(v2.X + lu - 2 * wcf / 3.00 - 3, wcf / 3.00);
                Vector2 v30 = new Vector2(v2.X + lu - 3 * wcf / 2.00 - 3, wcf / 2.00);
                Vector2 v31 = new Vector2(v30.X, -v30.Y);
                Vector2 v32 = new Vector2(v29.X, -v29.Y);
                Vector2 v33 = new Vector2(v2.X, v30.Y);
                Vector2 v34 = new Vector2(v33.X, -v33.Y);
                double dx = v2.X;
                if (tcpd < dn)
                {
                    dx = (v5.Y - oal * (td - tcpd) / 4 / tcl - tcpd / 2) * 2 * tcl / (td - tcpd);
                }
                Vector2 v35 = new Vector2(dx, v5.Y);
                Vector2 v36 = new Vector2(dx, v14.Y);
                Vector2 v37 = new Vector2(v4.X, v34.Y);
                Vector2 v38 = new Vector2(v37.X, -v37.Y);
                Vector2 v39 = new Vector2(v5.X, v38.Y);
                Vector2 v40 = new Vector2(v39.X, -v39.Y);
                Vector2 v41 = new Vector2(v1.X - 2, v1.Y);
                Vector2 v42 = new Vector2(v9.X + 2, v1.Y);
                Vector2 v43 = new Vector2(2 * v1.X - v17.X, v2.Y);
                Vector2 v44 = new Vector2(2 * v1.X - v2.X, v17.Y);
                Vector2 v80 = new Vector2(v8.X - drvl - 1 * scale, v7.Y);
                Vector2 v81 = new Vector2(v80.X, -v80.Y);
                Vector2 v82 = new Vector2(v80.X, ds / 2.00);
                Vector2 v83 = new Vector2(v82.X, -v82.Y);
                //柄方
                Vector2 v45 = new Vector2(oal + oal / 15.00, v8.Y - (v20.Y - v25.Y) * Math.Cos(45 * pi / 180));
                Vector2 v46 = new Vector2(v45.X - (v20.Y - v25.Y) / 2.00, v45.Y + (v20.Y - v25.Y) / 2.00);
                Vector2 v47 = new Vector2(v45.X * 2 - v46.X, v46.Y);
                Vector2 v48 = new Vector2(v45.X + v45.Y, v1.Y);
                Vector2 v49 = new Vector2(v45.X + v46.Y, v48.Y + v47.X - v45.X);
                Vector2 v50 = new Vector2(v49.X, -v49.Y);
                Vector2 v51 = new Vector2(v45.X, -v45.Y);
                Vector2 v52 = new Vector2(v47.X, -v47.Y);
                Vector2 v53 = new Vector2(v46.X, -v46.Y);
                Vector2 v54 = new Vector2(v45.X * 2 - v48.X, v48.Y);
                Vector2 v55 = new Vector2(v45.X * 2 - v50.X, v50.Y);
                Vector2 v56 = new Vector2(v45.X * 2 - v49.X, v49.Y);
                Vector2 v57 = new Vector2(v45.X - ds / 2.00 - 2, 0);
                Vector2 v58 = new Vector2(v45.X + ds / 2.00 + 2, 0);
                Vector2 v59 = new Vector2(v45.X, ds / 2.00 + 2);
                Vector2 v60 = new Vector2(v59.X, -v59.Y);
                string tctr = Convert.ToString(data["tctr"]);
                //检测
                /*
                Vector2[] v1000 = { v1, v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20
                    ,v21,v22,v23,v24,v25,v26,v27,v28,v29,v30,v31,v32,v33,v34,v35,v36,v37,v38,v39,v40,v41,v42,v43,v44
                ,v45,v46,v47,v48,v49,v50,v51,v52,v53,v54,v55,v56,v57,v58,v59,v60,v80,v81,v82,v83};
               
                fun.seevector2(dxf,0.6,v1000);//计算各个点
                */

                if (!tctr.Equals("0"))
                {
                    Vector2 a1 = fun.Polar(v3, fun.CalAngle(v3, v4), fun.CalDistance(v3, v4) / 2);
                    Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                    Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                    Line line101 = new Line(a1, a2);
                    dxf.AddEntity(line101);
                    fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");
                }
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v80 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v81, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v1 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v2, v17 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v4, v38 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v37, v15 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v5, v39 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v40, v14 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v6, v13 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v7, v12 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v8, v21 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v20, v25 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v26, v11 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v21, v18 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v18, v19 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v19, v20 };
                fun.drawBLine(dxf, Line30, 0.3, contour);
                Vector2[] Line31 = { v25, v24 };
                fun.drawBLine(dxf, Line31, 0.3, contour);
                Vector2[] Line32 = { v24, v23 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v23, v26 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                //Arc Arc1 = new Arc(v22, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
                //Arc Arc2 = new Arc(v27, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v21));
                Arc1.Vertexes.Add(new LwPolylineVertex(v20));
                Arc1.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v25));
                Arc2.Vertexes.Add(new LwPolylineVertex(v26));
                Arc2.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                /* LwPolyline Arc4 = new LwPolyline();
                 Arc4.Vertexes.Add(new LwPolylineVertex(v18));
                 Arc4.Vertexes.Add(new LwPolylineVertex(v19));
                 Arc4.Vertexes[0].Bulge = 1 * scale / ((v18.Y - v19.Y) / 2.00);
                fun.PolyFill(dxf, Arc4, 0.3, contour);*/
                Vector2 v61 = fun.Polar(v18, pi, oal * (1.5 / 194.5));
                Vector2 v64 = fun.Polar(v61, pi / -2 + 0.01 * pi / 180, oal);
                Line line11 = new Line(v61, v64);
                Arc arc1 = fun.DrawArc5(v18, line11, v19);
                Arc arc2 = fun.DrawArc5(v24, line11, v23);
                fun.drawBArc(dxf, arc1, 0.3, contour);
                fun.drawBArc(dxf, arc2, 0.3, contour);
                /* LwPolyline Arc5 = new LwPolyline();
                 Arc5.Vertexes.Add(new LwPolylineVertex(v24));
                 Arc5.Vertexes.Add(new LwPolylineVertex(v23));
                 Arc5.Vertexes[0].Bulge = 1 * scale / ((v24.Y - v23.Y) / 2.00);
                 fun.PolyFill(dxf, Arc5, 0.3, contour);*/
                Line line34 = new Line(v5, v35);
                line34.Lineweight = Lineweight.W25;
                line34.Layer = additionalline;
                dxf.AddEntity(line34);
                Line line35 = new Line(v14, v36);
                line35.Lineweight = Lineweight.W25;
                line35.Layer = additionalline;
                dxf.AddEntity(line35);
                /*Vector2[] Line36 = { v34, v31 };
                fun.drawBLine(dxf, Line36, 0.3, contour);
                Vector2[] Line37 = { v33, v30 };
                fun.drawBLine(dxf, Line37, 0.3, contour);*/
                Line Line36 = new Line(v34, v31);
                Line36.Layer = contour;
                dxf.AddEntity(Line36);
                Line Line37 = new Line(v33, v30);
                Line37.Layer = contour;
                dxf.AddEntity(Line37);
                Vector2[] Line38 = { v41, v42 };
                fun.drawPlinetype(dxf, Line38, 0.15, centre, Linetype.Center);
                Vector2[] Line39 = { v18, v20 };
                fun.drawBLine(dxf, Line39, 0.15, contour);
                Vector2[] Line40 = { v19, v21 };
                fun.drawBLine(dxf, Line40, 0.15, contour);
                Vector2[] Line41 = { v24, v26 };
                fun.drawBLine(dxf, Line41, 0.15, contour);
                Vector2[] Line42 = { v23, v25 };
                fun.drawBLine(dxf, Line42, 0.15, contour);
                Line Line43 = new Line(v1, v43);
                Line Line44 = new Line(v1, v44);
                List<Vector3> point1 = new List<Vector3>
            {
                fun.Tothree(v31),
                fun.Tothree(v32),
                fun.Tothree(v28),
                fun.Tothree(v29),
                fun.Tothree(v30),
            };

                Spline spline1 = new Spline(point1);
                spline1.Layer = contour;
                dxf.AddEntity(spline1);
                //fun.PolyFill(dxf, spline1, 0.3, contour);
                Vector2[] Line55 = { v80, v81 };
                fun.drawBLine(dxf, Line55, 0.3, contour);
                Vector2[] Line56 = { v82, v8 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v83, v11 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                //柄方
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v47));
                poly1.Vertexes.Add(new LwPolylineVertex(v49));
                poly1.Vertexes.Add(new LwPolylineVertex(v50));
                poly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v52));
                poly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v53));
                poly1.Vertexes.Add(new LwPolylineVertex(v55));
                poly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v56));
                poly1.Vertexes.Add(new LwPolylineVertex(v46));
                poly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.3, contour);
                Line Line53 = new Line(v57, v58);
                Line Line54 = new Line(v59, v60);
                //主视图图层
                //Line43.Layer = dimensioning;
                // Line44.Layer = dimensioning;
                //柄方图层
                Line53.Layer = centre;
                Line54.Layer = centre;
                Line53.Linetype = Linetype.Center;
                Line54.Linetype = Linetype.Center;
                //主视图
                //dxf.AddEntity(Line43);
                // dxf.AddEntity(Line44);
                //柄方
                dxf.AddEntity(Line53);
                dxf.AddEntity(Line54);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.5 * (oal / 40);
                dimensionStyle.ExtLineExtend = 0.6 * (oal / 40);//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = (2.5 * (oal / 40)) / 4.0;
                double offset = 20 * (oal / 40);
                double height = (2.5 * (oal / 40)) / 2.0;
                double arrowsize = 0.5 * (oal / 40);
                //线段尺寸标注
                //尺寸1
                /*
                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v1, v43), new Line(v1, v44), offset, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);*/

                string l5;
                string kr;

                if (mc == 0) { l5 = "8P"; kr = "4°30′"; }
                else if (mc == 1) { l5 = "4P"; kr = "8°30′"; }
                else if (mc == 2) { l5 = "2P"; kr = "17°"; }
                else if (mc == 3) { l5 = "6P"; kr = "6°"; }
                else { l5 = ""; kr = ""; }

                if (mc == 3 && tp > 2.5)
                {
                    Line line01 = new Line(fun.Polar(v80, pi, 4), fun.Polar(v81, pi, 4)); fun.drawBline(dxf, line01, 0.3, contour);
                }
                if (mc == 1 && tp > 2.5)
                {
                    Line line01 = new Line(fun.Polar(v80, pi, 4), fun.Polar(v81, pi, 4)); fun.drawBline(dxf, line01, 0.3, contour);
                    Line line02 = new Line(fun.Polar(v80, pi, 6.5), fun.Polar(v81, pi, 6.5)); fun.drawBline(dxf, line02, 0.3, contour);
                }


                LinearDimension dim00 = new LinearDimension(new Line(v3, v2), offset / 2.0, 0, dimensionStyle);
                dim00.UserText = "TCL = " + l5;
                dxf.AddEntity(dim00);

                fun.jdbz2(dxf, new Line(v3, v4), new Line(v2, v3), offset, height, arrowsize, 0.6, "KAPR=" + kr, "", "");
                //  fun.jdbz2(dxf, new Line(v1, v43), new Line(v1, v44), offset /2.0, height, arrowsize , 0.4, "SIG = " + Math.Round(sig / (pi / 180), 2) + "°", "", "");
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v3, v16), -v3.X + v43.X - offset - 5, 270, dimensionStyle);
                dim2.UserText = "TD = " + Math.Round(lu / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                double toh = Convert.ToDouble(data["thltctrh"]);
                double tol = Convert.ToDouble(data["thltctrl"]);
                if (toh == 0 && tol == 0)
                {
                    LinearDimension dim3 = new LinearDimension(new Line(v17, v15), (-offset - 5) / 3.0, 0, dimensionStyle);
                    dim3.UserText = "THL = " + Math.Round(thl / scale, 2);
                    dxf.AddEntity(dim3);
                }
                else
                {
                    fun.dimrot(dxf, v17, v15, 0, -offset * (2 / 3.0), height, arrowsize, 2.5, "THL = " + Math.Round(thl / scale, 2), toh + "", tol + "");
                }
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v17, v13), -offset * (2 / 3.0), 0, dimensionStyle);
                dim4.UserText = "LU = " + Math.Round(lu / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                double toh1 = Convert.ToDouble(data["oaltctrh"]);
                double tol1 = Convert.ToDouble(data["oaltctrl"]);
                string oaltctr = Convert.ToString(data["oaltctr"]);
                if (toh1 == 0 && tol1 == 0)
                {
                    if (oaltctr.Equals("0"))
                    {
                        LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset, 0, dimensionStyle);
                        dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                        dxf.AddEntity(dim5);
                    }
                    else
                    {
                        LinearDimension dim7 = new LinearDimension(new Line(v17, v10), -offset, 0, dimensionStyle);
                        dim7.UserText = "OAL = " + Math.Round(oal / scale, 2) + "  " + oaltctr;
                        dxf.AddEntity(dim7);
                    }
                }
                else
                {
                    fun.dimrot(dxf, v17, v10, 0, -offset, height, arrowsize, 2.5, "OAL = " + Math.Round(oal / scale, 2), toh1 + "", tol1 + "");
                }

                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v23, v26), (-offset - (v26.Y - v11.Y)) / 3.0, 0, dimensionStyle);
                dim6.UserText = "DRVL = " + Math.Round(drvl / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                string tcdconws = Convert.ToString(data["tcdconws"]);
                if (tcdconws.Equals("0"))
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v80, v81), (v9.X - v80.X + offset) / 2.0, 270, dimensionStyle);
                    dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2);
                    dxf.AddEntity(dim7);
                }
                else
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v80, v81), (v9.X - v80.X + offset) / 2.0, 270, dimensionStyle);
                    dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2) + "  " + tcdconws;
                    dxf.AddEntity(dim7);
                }


                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v46, v50), -offset / 2.0, 135, dimensionStyle);
                dim8.UserText = "DRVSC = " + Math.Round(drvsc / scale, 2);
                dxf.AddEntity(dim8);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
                hatchpoly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
                hatchpoly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
                hatchpoly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
                hatchpoly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 89, 2.5 * (td / 3.0), hline1, harc1, hatching);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v1.X - 210 + (v45.X + v8.Y - v1.X) / 2.00, v1.Y + 148.5), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            else if (fdc == 1)
            {
                double soal = Convert.ToDouble(data["oal"]);
                double scale = Convert.ToDouble(data["scale"]); //放大系数
                if (scale == 0 && soal < 105)
                {
                    scale = 2.0;
                }
                else if (scale == 0 && soal < 210)
                {
                    scale = 1.0;
                }
                else if (scale == 0)
                {
                    scale = 0.5;
                }
                double pi = Math.PI;
                double td = Convert.ToDouble(data["td"]) * scale;
                double dmm = Convert.ToDouble(data["dmm"]) * scale;
                double tp = Convert.ToDouble(data["tp"]) * scale;
                double dn = Convert.ToDouble(data["dn"]) * scale;
                if (dn == 0)
                {
                    dn = td - 1.1325 * tp - 0.15;
                }
                double mc = Convert.ToDouble(data["mc"]);
                double qxzj;
                if (mc == 0)
                {
                    qxzj = 4.5 * pi / 180;
                }
                if (mc == 1)
                {
                    qxzj = 8.5 * pi / 180;
                }
                if (mc == 2)
                {
                    qxzj = 17 * pi / 180;
                }
                else
                {
                    qxzj = 6 * pi / 180;
                }

                double tcl;
                if (mc == 0)
                {
                    tcl = 8 * tp;
                }
                else if (mc == 1)
                {
                    tcl = 4 * tp;
                }
                else if (mc == 2)
                {
                    tcl = 2 * tp;
                }
                else
                {
                    tcl = 6 * tp;
                }

                if (tcl == 0)
                {
                    tcl = tp * 2.3;
                }
                double tcpd = td - tcl * Math.Tan(qxzj);
                double thl = Convert.ToDouble(data["thl"]) * scale;
                double lu = Convert.ToDouble(data["lu"]) * scale;
                if (lu == 0)
                {
                    lu = thl * 39 / 22;
                }
                double oal = Convert.ToDouble(data["oal"]) * scale;
                double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
                double drvl = Convert.ToDouble(data["drvl"]) * scale;
                double sig = Convert.ToDouble(data["sig"]) * pi / 180;
                double FHA = Convert.ToDouble(data["fha"]);
                double ta = Convert.ToDouble(data["ta"]) * pi / 180;
                double ds = dmm - 0.08 * scale;//柄方外圆
                double ds1 = dmm * 1 / 10.0;
                double isframe = Convert.ToDouble(data["isframe"]);
                //坐标
                //主视图
                Vector2 v2 = new Vector2(-oal / 2.00, tcpd / 2.00);
                Vector2 v1 = new Vector2(v2.X - v2.Y / Math.Tan(sig / 2.00), 0);
                Vector2 v3 = new Vector2(v2.X + tcl, td / 2.00);
                Vector2 v4 = new Vector2(v2.X + thl, v3.Y);
                Vector2 v5 = new Vector2((td - dn) / 2.00 + v4.X, dn / 2.00);
                Vector2 v6 = new Vector2(v2.X + lu, v5.Y);
                Vector2 p7_1 = fun.Polar(v1, pi / 2, dmm / 2.0);
                Vector2 p7_2 = fun.Polar(p7_1, 0, oal);
                Vector2 v7;
                if (v6.Y == dmm / 2.0)
                {
                    v7 = v6;
                }
                else if (v6.Y < dmm / 2.0)
                {
                    v7 = fun.Inters(p7_1, p7_2, v6, fun.Polar(v6, pi / 4, oal));
                }
                else
                {
                    v7 = fun.Inters(p7_1, p7_2, v6, fun.Polar(v6, pi / -4, oal));
                }
                //Vector2 v7 = new Vector2((dmm - dn) / 2.00 / Math.Tan(ta) + v6.X, dmm / 2.00);
                Vector2 v8 = new Vector2(v2.X + oal - 0.15 * dmm, ds / 2);
                Vector2 v9 = new Vector2(v2.X + oal, 0.35 * dmm);
                Vector2 v10 = new Vector2(v9.X, -v9.Y);
                Vector2 v11 = new Vector2(v8.X, -v8.Y);
                Vector2 v12 = new Vector2(v7.X, -v7.Y);
                Vector2 v13 = new Vector2(v6.X, -v6.Y);
                Vector2 v14 = new Vector2(v5.X, -v5.Y);
                Vector2 v15 = new Vector2(v4.X, -v4.Y);
                Vector2 v16 = new Vector2(v3.X, -v3.Y);
                Vector2 v17 = new Vector2(v2.X, -v2.Y);
                Vector2 v19 = new Vector2(v8.X - drvl, ds1);
                Vector2 v18 = fun.Inters(v7, v8, v19, fun.Polar(v19, pi / 2, 150));
                Vector2 v20 = new Vector2(v8.X, v19.Y);
                Vector2 v21 = new Vector2(v20.X, v18.Y);
                Vector2 v22 = new Vector2(v21.X - (v18.Y - v19.Y) / 2.00 * Math.Tan(60 * pi / 180), (v18.Y + v19.Y) / 2.00);
                Vector2 v23 = new Vector2(v18.X, -v18.Y);
                Vector2 v24 = new Vector2(v19.X, -v19.Y);
                Vector2 v25 = new Vector2(v20.X, -v20.Y);
                Vector2 v26 = new Vector2(v21.X, -v21.Y);
                Vector2 v27 = new Vector2(v22.X, -v22.Y);
                Vector2 v41 = new Vector2(v1.X - 2, v1.Y);
                Vector2 v42 = new Vector2(v9.X + 2, v1.Y);
                Vector2 v43 = new Vector2(2 * v1.X - v17.X, v2.Y);
                Vector2 v44 = new Vector2(2 * v1.X - v2.X, v17.Y);
                Vector2 v80 = new Vector2(v8.X - drvl - 1 * scale, v7.Y);
                Vector2 v81 = new Vector2(v80.X, -v80.Y);
                Vector2 v82 = new Vector2(v80.X, ds / 2.00);
                Vector2 v83 = new Vector2(v82.X, -v82.Y);
                //柄方
                Vector2 v45 = new Vector2(oal + oal / 15.00, v8.Y - (v20.Y - v25.Y) * Math.Cos(45 * pi / 180));
                Vector2 v46 = new Vector2(v45.X - (v20.Y - v25.Y) / 2.00, v45.Y + (v20.Y - v25.Y) / 2.00);
                Vector2 v47 = new Vector2(v45.X * 2 - v46.X, v46.Y);
                Vector2 v48 = new Vector2(v45.X + v45.Y, v1.Y);
                Vector2 v49 = new Vector2(v45.X + v46.Y, v48.Y + v47.X - v45.X);
                Vector2 v50 = new Vector2(v49.X, -v49.Y);
                Vector2 v51 = new Vector2(v45.X, -v45.Y);
                Vector2 v52 = new Vector2(v47.X, -v47.Y);
                Vector2 v53 = new Vector2(v46.X, -v46.Y);
                Vector2 v54 = new Vector2(v45.X * 2 - v48.X, v48.Y);
                Vector2 v55 = new Vector2(v45.X * 2 - v50.X, v50.Y);
                Vector2 v56 = new Vector2(v45.X * 2 - v49.X, v49.Y);
                Vector2 v57 = new Vector2(v45.X - ds / 2.00 - 2, 0);
                Vector2 v58 = new Vector2(v45.X + ds / 2.00 + 2, 0);
                Vector2 v59 = new Vector2(v45.X, ds / 2.00 + 2);
                Vector2 v60 = new Vector2(v59.X, -v59.Y);
                string tctr = Convert.ToString(data["tctr"]);
                if (!tctr.Equals("0"))
                {
                    Vector2 a1 = fun.Polar(v3, fun.CalAngle(v3, v4), fun.CalDistance(v3, v4) / 2);
                    Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                    Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                    Line line101 = new Line(a1, a2);
                    dxf.AddEntity(line101);
                    fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

                }
                //线段
                //主视图

                double dx = v2.X;
                if (tcpd < dn)
                {
                    dx = (v5.Y - oal * (td - tcpd) / 4 / tcl - tcpd / 2) * 2 * tcl / (td - tcpd);
                }
                Vector2 v35 = new Vector2(dx, v5.Y);
                Vector2 v36 = new Vector2(dx, v14.Y);
                Line line34 = new Line(v5, v35);
                line34.Lineweight = Lineweight.W25;
                line34.Layer = additionalline;
                dxf.AddEntity(line34);
                Line line35 = new Line(v14, v36);
                line35.Lineweight = Lineweight.W25;
                line35.Layer = additionalline;
                dxf.AddEntity(line35);

                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v80 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v81, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v1 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v2, v17 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line23 = { v6, v13 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v7, v12 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v8, v21 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v20, v25 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v26, v11 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v21, v18 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v18, v19 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v19, v20 };
                fun.drawBLine(dxf, Line30, 0.3, contour);
                Vector2[] Line31 = { v25, v24 };
                fun.drawBLine(dxf, Line31, 0.3, contour);
                Vector2[] Line32 = { v24, v23 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v23, v26 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                //Arc Arc1 = new Arc(v22, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
                //Arc Arc2 = new Arc(v27, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v21));
                Arc1.Vertexes.Add(new LwPolylineVertex(v20));
                Arc1.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v25));
                Arc2.Vertexes.Add(new LwPolylineVertex(v26));
                Arc2.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                LwPolyline Arc4 = new LwPolyline();
                Arc4.Vertexes.Add(new LwPolylineVertex(v18));
                Arc4.Vertexes.Add(new LwPolylineVertex(v19));
                Arc4.Vertexes[0].Bulge = 1 * scale / ((v18.Y - v19.Y) / 2.00);
                fun.PolyFill(dxf, Arc4, 0.3, contour);
                LwPolyline Arc5 = new LwPolyline();
                Arc5.Vertexes.Add(new LwPolylineVertex(v24));
                Arc5.Vertexes.Add(new LwPolylineVertex(v23));
                Arc5.Vertexes[0].Bulge = 1 * scale / ((v24.Y - v23.Y) / 2.00);
                fun.PolyFill(dxf, Arc5, 0.3, contour);
                Vector2[] Line38 = { v41, v42 };
                fun.drawPlinetype(dxf, Line38, 0.15, centre, Linetype.Center);
                Vector2[] Line39 = { v18, v20 };
                fun.drawBLine(dxf, Line39, 0.15, contour);
                Vector2[] Line40 = { v19, v21 };
                fun.drawBLine(dxf, Line40, 0.15, contour);
                Vector2[] Line41 = { v24, v26 };
                fun.drawBLine(dxf, Line41, 0.15, contour);
                Vector2[] Line42 = { v23, v25 };
                fun.drawBLine(dxf, Line42, 0.15, contour);
                Line Line43 = new Line(v1, v43);
                Line Line44 = new Line(v1, v44);
                Vector2[] Line55 = { v80, v81 };
                fun.drawBLine(dxf, Line55, 0.3, contour);
                Vector2[] Line56 = { v82, v8 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v83, v11 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                //柄方
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v47));
                poly1.Vertexes.Add(new LwPolylineVertex(v49));
                poly1.Vertexes.Add(new LwPolylineVertex(v50));
                poly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v52));
                poly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v53));
                poly1.Vertexes.Add(new LwPolylineVertex(v55));
                poly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v56));
                poly1.Vertexes.Add(new LwPolylineVertex(v46));
                poly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.3, contour);
                Line Line53 = new Line(v57, v58);
                Line Line54 = new Line(v59, v60);
                //主视图图层
                Line43.Layer = dimensioning;
                Line44.Layer = dimensioning;
                //柄方图层
                Line53.Layer = centre;
                Line54.Layer = centre;
                Line53.Linetype = Linetype.Center;
                Line54.Linetype = Linetype.Center;
                //主视图
                dxf.AddEntity(Line43);
                dxf.AddEntity(Line44);
                //柄方
                dxf.AddEntity(Line53);
                dxf.AddEntity(Line54);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.5 * (oal / 40);
                dimensionStyle.ExtLineExtend = 0.6 * (oal / 40);//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                double height = (2.5 * (oal / 40)) / 2.0;
                double arrowsize = 0.5 * (oal / 40);
                //文本样式
                dimensionStyle.TextHeight = (2.5 * (oal / 40)) / 4.0;
                double offset = 20 * (oal / 40);
                //线段尺寸标注
                //尺寸1
                /*Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v1, v43), new Line(v1, v44), offset, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);*/
                //fun.jdbz2(dxf, new Line(v1, v43), new Line(v1, v44), offset /2.0, height , arrowsize , 0.4, "SIG = " + Math.Round(sig / (pi / 180), 2) + "°", "", "");
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v3, v16), -v3.X + v43.X - offset - 5, 270, dimensionStyle);
                dim2.UserText = "TD = " + Math.Round(lu / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                double toh = Convert.ToDouble(data["thltctrh"]);
                double tol = Convert.ToDouble(data["thltctrl"]);
                if (toh == 0 && tol == 0)
                {
                    LinearDimension dim3 = new LinearDimension(new Line(v17, v15), -offset * (2 / 3.0), 0, dimensionStyle);
                    dim3.UserText = "THL = " + Math.Round(thl / scale, 2);
                    dxf.AddEntity(dim3);
                }
                else
                {
                    fun.dimrot(dxf, v17, v15, 0, -offset * (2 / 3.0), height, arrowsize, 2.5, "THL = " + Math.Round(thl / scale, 2), toh + "", tol + "");
                }
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v17, v13), (-offset - 5) / 3.0, 0, dimensionStyle);
                dim4.UserText = "LU = " + Math.Round(lu / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                double toh1 = Convert.ToDouble(data["oaltctrh"]);
                double tol1 = Convert.ToDouble(data["oaltctrl"]);
                string oaltctr = Convert.ToString(data["oaltctr"]);
                if (toh1 == 0 && tol1 == 0)
                {
                    if (oaltctr.Equals("0"))
                    {
                        LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset, 0, dimensionStyle);
                        dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                        dxf.AddEntity(dim5);
                    }
                    else
                    {
                        LinearDimension dim7 = new LinearDimension(new Line(v17, v10), -offset, 0, dimensionStyle);
                        dim7.UserText = "OAL = " + Math.Round(oal / scale, 2) + "  " + oaltctr;
                        dxf.AddEntity(dim7);
                    }
                }
                else
                {
                    fun.dimrot(dxf, v17, v10, 0, -offset, height, arrowsize, 2.5, "OAL = " + Math.Round(oal / scale, 2), toh1 + "", tol1 + "");
                }

                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v23, v26), (-offset - (v26.Y - v11.Y)) / 3.0, 0, dimensionStyle);
                dim6.UserText = "DRVL = " + Math.Round(drvl / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                string tcdconws = Convert.ToString(data["tcdconws"]);
                if (tcdconws.Equals("0"))
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v80, v81), (v9.X - v80.X + offset) / 2.0, 270, dimensionStyle);
                    dim7.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                    dxf.AddEntity(dim7);
                }
                else
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v80, v81), (v9.X - v80.X + offset) / 2.0, 270, dimensionStyle);
                    dim7.UserText = "DMM = " + Math.Round(dmm / scale, 2) + "  " + tcdconws;
                    dxf.AddEntity(dim7);
                }

                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v46, v50), -offset / 2.0, 135, dimensionStyle);
                dim8.UserText = "DRVSC = " + Math.Round(drvsc / scale, 2);
                dxf.AddEntity(dim8);
                //填充柄方
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
                hatchpoly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
                hatchpoly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
                hatchpoly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
                hatchpoly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 89, 2.5 * (td / 3.0), hline1, harc1, hatching);
                /* //填充螺旋槽
                 LwPolyline hatchpoly2 = new LwPolyline();
                 hatchpoly2.Vertexes.Add(new LwPolylineVertex(v2));
                 hatchpoly2.Vertexes.Add(new LwPolylineVertex(v3));
                 hatchpoly2.Vertexes.Add(new LwPolylineVertex(v4));
                 hatchpoly2.Vertexes.Add(new LwPolylineVertex(v5));
                 hatchpoly2.Vertexes.Add(new LwPolylineVertex(v6));
                 hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
                 hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
                 hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
                 hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
                 hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
                 hatchpoly2.IsClosed = true;
                 String[] htype2 = new String[100];
                 Line[] hline2 = new Line[100];
                 int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
                 for (int i = 0; i < hnumst2; i++)
                 {
                     htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                     if (htype2[i] == "Line")
                     {
                         hline2[i] = (Line)hatchpoly2.Explode()[i];
                     }
                 }
                 var x = lu / 5.00 * Math.Tan(FHA * pi / 180);
                 if (x < tcpd / 2.00)
                 {
                     fun.hatchsuboflinew(dxf, htype2, hnumst2, -FHA, lu / 2.00 * 8 * Math.Sin(FHA * pi / 180), hline2, contour, 0.3);
                 }
                 else
                 {
                     fun.hatchsuboflinew(dxf, htype2, hnumst2, -FHA, lu / 5.00 * 8 * Math.Sin(FHA * pi / 180), hline2, contour, 0.3);
                 }*/


                double lxxx = Convert.ToDouble(data["lxxx"]);
                if (lxxx == 0)
                {
                    Vector2 v01 = fun.Polar(v17, 90 * pi / 180, tcpd / 4);
                    Vector2 v02p = fun.Polar(v01, -FHA * pi / 180, 10);
                    Vector2 v02 = fun.Inters(v01, v02p, v15, v16);
                    Vector2 v03 = fun.Polar(v17, 90 * pi / 180, tcpd / 6 * 4);
                    Vector2 v04p = fun.Polar(v03, -FHA * pi / 180, 10);
                    Vector2 v04;
                    if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v03.Y - v15.Y)) * 180 / pi)
                    {
                        v04 = fun.Inters(v03, v04p, v4, v15);
                    }
                    else
                    {
                        v04 = fun.Inters(v03, v04p, v15, v16);
                    }

                    Vector2 v05 = new Vector2(v2.X, v2.Y);
                    Vector2 v06p = fun.Polar(v05, -FHA * pi / 180, 10);
                    Vector2 v06;
                    if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v05.Y - v15.Y)) * 180 / pi)
                    {
                        v06 = fun.Inters(v05, v06p, v4, v15);
                    }
                    else
                    {
                        v06 = fun.Inters(v05, v06p, v15, v16);
                    }
                    Vector2 v07p = fun.Polar(v05, 90 * pi / 180, (v03.Y - v01.Y));
                    Vector2 v08p = fun.Polar(v07p, -FHA * pi / 180, 10);
                    Vector2 v07 = fun.Inters(v07p, v08p, v3, v4);
                    Vector2 v08;
                    if (FHA <= 90 - Math.Atan((v15.X - v07.X) / (v07.Y - v15.Y)) * 180 / pi)
                    {
                        v08 = fun.Inters(v07, v08p, v4, v15);
                    }
                    else
                    {
                        v08 = fun.Inters(v07, v08p, v15, v16);
                    }




                    Vector2[] Line01 = { v4, v15 };
                    fun.drawBLine(dxf, Line01, 0.3, contour);
                    Line line01 = new Line(v01, v02);
                    line01.Lineweight = Lineweight.W25;
                    line01.Layer = additionalline;
                    dxf.AddEntity(line01);
                    Line line02 = new Line(v03, v04);
                    line02.Lineweight = Lineweight.W25;
                    line02.Layer = additionalline;
                    dxf.AddEntity(line02);
                    Line line03 = new Line(v05, v06);
                    line03.Lineweight = Lineweight.W25;
                    line03.Layer = additionalline;
                    dxf.AddEntity(line03);
                    Line line04 = new Line(v07, v08);
                    line04.Lineweight = Lineweight.W25;
                    line04.Layer = additionalline;
                    dxf.AddEntity(line04);


                    LwPolyline hatchpoly01 = new LwPolyline();
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v01));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v17));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v16));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v02));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v01));
                    hatchpoly01.IsClosed = true;
                    String[] htype01 = new String[100];
                    Line[] hline01 = new Line[100];
                    Arc[] harc01 = new Arc[100];
                    int hnumst01 = hatchpoly01.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst01; i++)
                    {
                        htype01[i] = hatchpoly01.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype01[i] == "Line")
                        {
                            hline01[i] = (Line)hatchpoly01.Explode()[i];
                        }
                        if (htype01[i] == "Arc")
                        {
                            harc01[i] = (Arc)hatchpoly01.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype01, hnumst01, 89, 2.5 * (td / 3.0), hline01, harc01, hatching);





                    LwPolyline hatchpoly02 = new LwPolyline();
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v03));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v04));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v15));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v06));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v05));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v03));
                    hatchpoly02.IsClosed = true;
                    String[] htype02 = new String[102];
                    Line[] hline02 = new Line[102];
                    Arc[] harc02 = new Arc[102];
                    int hnumst02 = hatchpoly02.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst02; i++)
                    {
                        htype02[i] = hatchpoly02.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype02[i] == "Line")
                        {
                            hline02[i] = (Line)hatchpoly02.Explode()[i];
                        }
                        if (htype02[i] == "Arc")
                        {
                            harc02[i] = (Arc)hatchpoly02.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype02, hnumst02, 89, 2.5 * (td / 3.0), hline02, harc02, hatching);


                    LwPolyline hatchpoly03 = new LwPolyline();
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v07));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v08));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v15));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v4));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v07));
                    hatchpoly03.IsClosed = true;
                    String[] htype03 = new String[103];
                    Line[] hline03 = new Line[103];
                    Arc[] harc03 = new Arc[103];
                    int hnumst03 = hatchpoly03.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst03; i++)
                    {
                        htype03[i] = hatchpoly03.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype03[i] == "Line")
                        {
                            hline03[i] = (Line)hatchpoly03.Explode()[i];
                        }
                        if (htype03[i] == "Arc")
                        {
                            harc03[i] = (Arc)hatchpoly03.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype03, hnumst03, 89, 2.5 * (td / 3.0), hline03, harc03, hatching);

                    Angular2LineDimension angdim2 = new Angular2LineDimension(new Line(v05, v06), new Line(v41, v42), offset * 5, dimensionStyle);
                    angdim2.UserText = "FHA = " + FHA + "°";
                    dxf.AddEntity(angdim2);

                    //fun.jdbz2(dxf, new Line(v41, v42), new Line(v05, v06), offset * 5, 2.5, 0.8, 0.4, "FHA = " + FHA + "°", "", "");


                }
                else
                {
                    Vector2 v01 = fun.Polar(v17, 90 * pi / 180, tcpd / 4);
                    Vector2 v02p = fun.Polar(v01, -FHA * pi / 180, 10);
                    Vector2 v02 = fun.Inters(v01, v02p, v15, v16);
                    Vector2 v03 = fun.Polar(v17, 90 * pi / 180, tcpd / 6 * 4);
                    Vector2 v04p = fun.Polar(v03, -FHA * pi / 180, 10);
                    Vector2 v04;
                    if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v03.Y - v15.Y)) * 180 / pi)
                    {
                        v04 = fun.Inters(v03, v04p, v4, v15);
                    }
                    else
                    {
                        v04 = fun.Inters(v03, v04p, v15, v16);
                    }

                    Vector2 v05 = new Vector2(v2.X, v2.Y);
                    Vector2 v06p = fun.Polar(v05, -FHA * pi / 180, 10);
                    Vector2 v06;
                    if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v05.Y - v15.Y)) * 180 / pi)
                    {
                        v06 = fun.Inters(v05, v06p, v4, v15);
                    }
                    else
                    {
                        v06 = fun.Inters(v05, v06p, v15, v16);
                    }
                    Vector2 v07p = fun.Polar(v05, 90 * pi / 180, (v03.Y - v01.Y));
                    Vector2 v08p = fun.Polar(v07p, -FHA * pi / 180, 10);
                    Vector2 v07 = fun.Inters(v07p, v08p, v3, v4);
                    Vector2 v08;
                    if (FHA <= 90 - Math.Atan((v15.X - v07.X) / (v07.Y - v15.Y)) * 180 / pi)
                    {
                        v08 = fun.Inters(v07, v08p, v4, v15);
                    }
                    else
                    {
                        v08 = fun.Inters(v07, v08p, v15, v16);
                    }

                    Vector2 a1 = new Vector2(v01.X, -v01.Y);
                    Vector2 a2 = new Vector2(v02.X, -v02.Y);
                    Vector2 a3 = new Vector2(v03.X, -v03.Y);
                    Vector2 a4 = new Vector2(v04.X, -v04.Y);
                    Vector2 a5 = new Vector2(v05.X, -v05.Y);
                    Vector2 a6 = new Vector2(v06.X, -v06.Y);
                    Vector2 a7 = new Vector2(v07.X, -v07.Y);
                    Vector2 a8 = new Vector2(v08.X, -v08.Y);



                    Vector2[] Line01 = { v4, v15 };
                    fun.drawBLine(dxf, Line01, 0.3, contour);
                    Line line01 = new Line(a1, a2);
                    line01.Lineweight = Lineweight.W25;
                    line01.Layer = additionalline;
                    dxf.AddEntity(line01);
                    Line line02 = new Line(a3, a4);
                    line02.Lineweight = Lineweight.W25;
                    line02.Layer = additionalline;
                    dxf.AddEntity(line02);
                    Line line03 = new Line(a5, a6);
                    line03.Lineweight = Lineweight.W25;
                    line03.Layer = additionalline;
                    dxf.AddEntity(line03);
                    Line line04 = new Line(a7, a8);
                    line04.Lineweight = Lineweight.W25;
                    line04.Layer = additionalline;
                    dxf.AddEntity(line04);

                    LwPolyline hatchpoly01 = new LwPolyline();
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(a1));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v2));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(v3));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(a2));
                    hatchpoly01.Vertexes.Add(new LwPolylineVertex(a1));
                    hatchpoly01.IsClosed = true;
                    String[] htype01 = new String[100];
                    Line[] hline01 = new Line[100];
                    Arc[] harc01 = new Arc[100];
                    int hnumst01 = hatchpoly01.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst01; i++)
                    {
                        htype01[i] = hatchpoly01.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype01[i] == "Line")
                        {
                            hline01[i] = (Line)hatchpoly01.Explode()[i];
                        }
                        if (htype01[i] == "Arc")
                        {
                            harc01[i] = (Arc)hatchpoly01.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype01, hnumst01, 89, 2.5 * (td / 3.0), hline01, harc01, hatching);


                    LwPolyline hatchpoly02 = new LwPolyline();
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(a3));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(a4));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(v4));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(a6));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(a5));
                    hatchpoly02.Vertexes.Add(new LwPolylineVertex(a3));
                    hatchpoly02.IsClosed = true;
                    String[] htype02 = new String[102];
                    Line[] hline02 = new Line[102];
                    Arc[] harc02 = new Arc[102];
                    int hnumst02 = hatchpoly02.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst02; i++)
                    {
                        htype02[i] = hatchpoly02.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype02[i] == "Line")
                        {
                            hline02[i] = (Line)hatchpoly02.Explode()[i];
                        }
                        if (htype02[i] == "Arc")
                        {
                            harc02[i] = (Arc)hatchpoly02.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype02, hnumst02, 89, 2.5 * (td / 3.0), hline02, harc02, hatching);


                    LwPolyline hatchpoly03 = new LwPolyline();
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(a7));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(a8));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v4));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(v15));
                    hatchpoly03.Vertexes.Add(new LwPolylineVertex(a7));
                    hatchpoly03.IsClosed = true;
                    String[] htype03 = new String[103];
                    Line[] hline03 = new Line[103];
                    Arc[] harc03 = new Arc[103];
                    int hnumst03 = hatchpoly03.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst03; i++)
                    {
                        htype03[i] = hatchpoly03.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype03[i] == "Line")
                        {
                            hline03[i] = (Line)hatchpoly03.Explode()[i];
                        }
                        if (htype03[i] == "Arc")
                        {
                            harc03[i] = (Arc)hatchpoly03.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype03, hnumst03, 89, 2.5 * (td / 3.0), hline03, harc03, hatching);

                    Angular2LineDimension angdim2 = new Angular2LineDimension(new Line(a5, a6), new Line(v41, v42), offset * 5, dimensionStyle);
                    angdim2.UserText = "FHA = " + FHA + "°";
                    dxf.AddEntity(angdim2);

                    //fun.jdbz2(dxf, new Line(v41, v42), new Line(a5, a6),  offset * 5, 2.5, 0.8, 0.4, "FHA = " + FHA + "°", "", "");

                }

                string l5;
                string kr;

                if (mc == 0) { l5 = "8P"; kr = "4°30′"; }
                else if (mc == 1) { l5 = "4P"; kr = "8°30′"; }
                else if (mc == 2) { l5 = "2P"; kr = "17°"; }
                else if (mc == 3) { l5 = "6P"; kr = "6°"; }
                else { l5 = ""; kr = ""; }

                if (mc == 3 && tp > 2.5)
                {
                    Line line01 = new Line(fun.Polar(v80, pi, 4), fun.Polar(v81, pi, 4)); fun.drawBline(dxf, line01, 0.3, contour);
                }
                if (mc == 1 && tp > 2.5)
                {
                    Line line01 = new Line(fun.Polar(v80, pi, 4), fun.Polar(v81, pi, 4)); fun.drawBline(dxf, line01, 0.3, contour);
                    Line line02 = new Line(fun.Polar(v80, pi, 6.5), fun.Polar(v81, pi, 6.5)); fun.drawBline(dxf, line02, 0.3, contour);
                }


                LinearDimension dim00 = new LinearDimension(new Line(v3, v2), offset, 0, dimensionStyle);
                dim00.UserText = "TCL = " + l5;
                dxf.AddEntity(dim00);

                fun.jdbz2(dxf, new Line(v3, v4), new Line(v2, v3), offset, 2.5, 2, 0.6, "KAPR=" + kr, "", "");
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v1.X - 210 + (v45.X + v8.Y - v1.X) / 2.00, v1.Y + 148.5), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (fdc == 2)
            {
                double soal = Convert.ToDouble(data["oal"]);
                double scale = Convert.ToDouble(data["scale"]); //放大系数
                if (scale == 0 && soal < 105)
                {
                    scale = 2.0;
                }
                else if (scale == 0 && soal < 210)
                {
                    scale = 1.0;
                }
                else if (scale == 0)
                {
                    scale = 0.5;
                }
                double pi = Math.PI;
                double td = Convert.ToDouble(data["td"]) * scale;
                double dmm = Convert.ToDouble(data["dmm"]) * scale;
                double tp = Convert.ToDouble(data["tp"]) * scale;
                double dn = Convert.ToDouble(data["dn"]) * scale;
                if (dn == 0)
                {
                    dn = td - 1.1325 * tp - 0.15;
                }
                double mc = Convert.ToDouble(data["mc"]);
                double qxzj;
                if (mc == 0)
                {
                    qxzj = 4.5 * pi / 180;
                }
                if (mc == 1)
                {
                    qxzj = 8.5 * pi / 180;
                }
                if (mc == 2)
                {
                    qxzj = 17 * pi / 180;
                }
                else
                {
                    qxzj = 6 * pi / 180;
                }

                double tcl;
                if (mc == 0)
                {
                    tcl = 8 * tp;
                }
                else if (mc == 1)
                {
                    tcl = 4 * tp;
                }
                else if (mc == 2)
                {
                    tcl = 2 * tp;
                }
                else
                {
                    tcl = 6 * tp;
                }

                if (tcl == 0)
                {
                    tcl = tp * 2.3;
                }
                double tcpd = td - tcl * Math.Tan(qxzj);
                double thl = Convert.ToDouble(data["thl"]) * scale;
                double lu = Convert.ToDouble(data["lu"]) * scale;
                if (lu == 0)
                {
                    lu = thl * 39 / 22;
                }
                double oal = Convert.ToDouble(data["oal"]) * scale;
                double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
                double drvl = Convert.ToDouble(data["drvl"]) * scale;
                double sig = Convert.ToDouble(data["sig"]) * pi / 180;
                double ta = Convert.ToDouble(data["ta"]) * pi / 180;
                double ds = dmm - 0.08 * scale;//柄方外圆
                double ds1 = dmm * 1 / 10.0;
                double isframe = Convert.ToDouble(data["isframe"]);
                //坐标
                //主视图
                Vector2 v2 = new Vector2(-oal / 2.00, tcpd / 2.00);
                Vector2 v1 = new Vector2(v2.X - v2.Y / Math.Tan(sig / 2.00), 0);
                Vector2 v3 = new Vector2(v2.X + tcl, td / 2.00);
                Vector2 v4 = new Vector2(v2.X + thl, v3.Y);
                Vector2 v5 = new Vector2((td - dn) / 2.00 + v4.X, dn / 2.00);
                Vector2 v6 = new Vector2(v2.X + lu, v5.Y);
                Vector2 p7_1 = fun.Polar(v1, pi / 2, dmm / 2.0);
                Vector2 p7_2 = fun.Polar(p7_1, 0, oal);
                Vector2 v7;
                if (v6.Y == dmm / 2.0)
                {
                    v7 = v6;
                }
                else if (v6.Y < dmm / 2.0)
                {
                    v7 = fun.Inters(p7_1, p7_2, v6, fun.Polar(v6, pi / 4, oal));
                }
                else
                {
                    v7 = fun.Inters(p7_1, p7_2, v6, fun.Polar(v6, pi / -4, oal));
                }
                //Vector2 v7 = new Vector2((dmm - dn) / 2.00 / Math.Tan(ta) + v6.X, dmm / 2.00);
                Vector2 v8 = new Vector2(v2.X + oal - 0.15 * dmm, ds / 2);
                Vector2 v9 = new Vector2(v2.X + oal, 0.35 * dmm);
                Vector2 v10 = new Vector2(v9.X, -v9.Y);
                Vector2 v11 = new Vector2(v8.X, -v8.Y);
                Vector2 v12 = new Vector2(v7.X, -v7.Y);
                Vector2 v13 = new Vector2(v6.X, -v6.Y);
                Vector2 v14 = new Vector2(v5.X, -v5.Y);
                Vector2 v15 = new Vector2(v4.X, -v4.Y);
                Vector2 v16 = new Vector2(v3.X, -v3.Y);
                Vector2 v17 = new Vector2(v2.X, -v2.Y);
                Vector2 v19 = new Vector2(v8.X - drvl, ds1);
                Vector2 v18 = fun.Inters(v7, v8, v19, fun.Polar(v19, pi / 2, 150));
                Vector2 v20 = new Vector2(v8.X, v19.Y);
                Vector2 v21 = new Vector2(v20.X, v18.Y);
                Vector2 v22 = new Vector2(v21.X - (v18.Y - v19.Y) / 2.00 * Math.Tan(60 * pi / 180), (v18.Y + v19.Y) / 2.00);
                Vector2 v23 = new Vector2(v18.X, -v18.Y);
                Vector2 v24 = new Vector2(v19.X, -v19.Y);
                Vector2 v25 = new Vector2(v20.X, -v20.Y);
                Vector2 v26 = new Vector2(v21.X, -v21.Y);
                Vector2 v27 = new Vector2(v22.X, -v22.Y);
                Vector2 v41 = new Vector2(v1.X - 2, v1.Y);
                Vector2 v42 = new Vector2(v9.X + 2, v1.Y);
                Vector2 v43 = new Vector2(2 * v1.X - v17.X, v2.Y);
                Vector2 v44 = new Vector2(2 * v1.X - v2.X, v17.Y);
                //Vector2 v61 = new Vector2(Math.Sqrt(tp * tp * 49 - (v2.Y-v33.Y)* (v2.Y - v33.Y))+v2.X, wcf * 5 / 4.00);
                //Vector2 v63 = new Vector2(v61.X, v33.Y*2-v61.Y);
                //Vector2 v64 = new Vector2(v61.X - (v61.Y - v33.Y) / ((v61.X - v3.X) / (v3.Y - v61.Y)), v33.Y);
                //Vector2 v62 = new Vector2(v64.X + Math.Sqrt((v61.X - v64.X) * (v61.X - v64.X) + (v61.Y - v33.Y) * (v61.Y - v33.Y)), wcf / 2.00);
                Vector2 v80 = new Vector2(v8.X - drvl - 1 * scale, v7.Y);
                Vector2 v81 = new Vector2(v80.X, -v80.Y);
                Vector2 v82 = new Vector2(v80.X, ds / 2.00);
                Vector2 v83 = new Vector2(v82.X, -v82.Y);
                //螺尖槽
                Vector2 v87 = new Vector2(v2.X + tcpd * 5 / 36, v2.Y);
                Vector2 v88 = new Vector2(v2.X + tcl + thl / 5, v87.Y - 5 * tcpd / 18);
                Vector2 v86 = new Vector2(v87.X, v87.Y - 5 * tcpd / 9);
                Vector2 v89 = new Vector2(v87.X, v87.Y + (v87.X - v2.X) * (td - tcpd) / 2 / tcl);
                Vector2 v84 = new Vector2(v87.X, -v89.Y);
                Vector2 v85 = new Vector2(v86.X + (-v88.Y - v84.Y) * (td - tcpd) / 2 / tcl, -v88.Y);
                Vector2 v90 = new Vector2((v87.X - v88.X) * v88.Y * v88.Y / (v87.Y - v88.Y) / (v87.Y - v88.Y) + v88.X, 0);
                Vector2 v91 = new Vector2(v90.X, v88.Y * 2 - v90.Y);
                Vector2 v93 = new Vector2(v88.X, v15.Y);
                double cl = Math.Sqrt((v85.Y - v84.Y) * (v85.Y - v84.Y) + (v85.X - v84.X) * (v85.X - v84.X)) / 2;
                double sr = Math.Sqrt(cl * cl + (cl * (td - tcpd) / 2 / tcl) * (cl * (td - tcpd) / 2 / tcl));
                double h = sr - (td - tcpd) * cl / 2 / tcl;
                Vector2 v94 = new Vector2(v85.X, v85.Y - sr);
                Vector2 v92 = new Vector2(v87.X, Math.Sqrt(sr * sr - (v85.X - v86.X) * (v85.X - v86.X)) + v94.Y);
                //排屑槽
                Vector2 v95 = new Vector2(v2.X + lu - 3, v88.Y);
                double cr = (v5.Y - v88.Y) * 2;
                Vector2 v96 = new Vector2(v95.X - cr * Math.Sin(60 * pi / 180), v5.Y);
                Vector2 v97 = new Vector2(v95.X, -v95.Y);
                Vector2 v98 = new Vector2(v96.X, -v96.Y);
                //柄方
                Vector2 v45 = new Vector2(oal + oal / 15.00, v8.Y - (v20.Y - v25.Y) * Math.Cos(45 * pi / 180));
                Vector2 v46 = new Vector2(v45.X - (v20.Y - v25.Y) / 2.00, v45.Y + (v20.Y - v25.Y) / 2.00);
                Vector2 v47 = new Vector2(v45.X * 2 - v46.X, v46.Y);
                Vector2 v48 = new Vector2(v45.X + v45.Y, v1.Y);
                Vector2 v49 = new Vector2(v45.X + v46.Y, v48.Y + v47.X - v45.X);
                Vector2 v50 = new Vector2(v49.X, -v49.Y);
                Vector2 v51 = new Vector2(v45.X, -v45.Y);
                Vector2 v52 = new Vector2(v47.X, -v47.Y);
                Vector2 v53 = new Vector2(v46.X, -v46.Y);
                Vector2 v54 = new Vector2(v45.X * 2 - v48.X, v48.Y);
                Vector2 v55 = new Vector2(v45.X * 2 - v50.X, v50.Y);
                Vector2 v56 = new Vector2(v45.X * 2 - v49.X, v49.Y);
                Vector2 v57 = new Vector2(v45.X - ds / 2.00 - 2, 0);
                Vector2 v58 = new Vector2(v45.X + ds / 2.00 + 2, 0);
                Vector2 v59 = new Vector2(v45.X, ds / 2.00 + 2);
                Vector2 v60 = new Vector2(v59.X, -v59.Y);
                string tctr = Convert.ToString(data["tctr"]);
                if (!tctr.Equals("0"))
                {
                    Vector2 a1 = fun.Polar(v3, fun.CalAngle(v3, v4), fun.CalDistance(v3, v4) / 2);
                    Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                    Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                    Line line101 = new Line(a1, a2);
                    dxf.AddEntity(line101);
                    fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

                }
                //线段
                double dx = v2.X;
                if (tcpd < dn)
                {
                    dx = (v5.Y - oal * (td - tcpd) / 4 / tcl - tcpd / 2) * 2 * tcl / (td - tcpd);
                }
                Vector2 v35 = new Vector2(dx, v5.Y);
                Vector2 v36 = new Vector2(dx, v14.Y);
                Line line34 = new Line(v5, v35);
                line34.Lineweight = Lineweight.W25;
                line34.Layer = additionalline;
                dxf.AddEntity(line34);
                Line line35 = new Line(v14, v36);
                line35.Lineweight = Lineweight.W25;
                line35.Layer = additionalline;
                dxf.AddEntity(line35);
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v80 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v81, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v1 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v2, v17 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line23 = { v6, v13 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v7, v12 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v8, v21 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v20, v25 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v26, v11 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v21, v18 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v18, v19 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v19, v20 };
                fun.drawBLine(dxf, Line30, 0.3, contour);
                Vector2[] Line31 = { v25, v24 };
                fun.drawBLine(dxf, Line31, 0.3, contour);
                Vector2[] Line32 = { v24, v23 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v23, v26 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                //Arc Arc1 = new Arc(v22, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
                //Arc Arc2 = new Arc(v27, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v21));
                Arc1.Vertexes.Add(new LwPolylineVertex(v20));
                Arc1.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v25));
                Arc2.Vertexes.Add(new LwPolylineVertex(v26));
                Arc2.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                LwPolyline Arc4 = new LwPolyline();
                Arc4.Vertexes.Add(new LwPolylineVertex(v18));
                Arc4.Vertexes.Add(new LwPolylineVertex(v19));
                Arc4.Vertexes[0].Bulge = 1 * scale / ((v18.Y - v19.Y) / 2.00);
                fun.PolyFill(dxf, Arc4, 0.3, contour);
                LwPolyline Arc5 = new LwPolyline();
                Arc5.Vertexes.Add(new LwPolylineVertex(v24));
                Arc5.Vertexes.Add(new LwPolylineVertex(v23));
                Arc5.Vertexes[0].Bulge = 1 * scale / ((v24.Y - v23.Y) / 2.00);
                fun.PolyFill(dxf, Arc5, 0.3, contour);
                Vector2[] Line38 = { v41, v42 };
                fun.drawPlinetype(dxf, Line38, 0.15, centre, Linetype.Center);
                Vector2[] Line39 = { v18, v20 };
                fun.drawBLine(dxf, Line39, 0.15, contour);
                Vector2[] Line40 = { v19, v21 };
                fun.drawBLine(dxf, Line40, 0.15, contour);
                Vector2[] Line41 = { v24, v26 };
                fun.drawBLine(dxf, Line41, 0.15, contour);
                Vector2[] Line42 = { v23, v25 };
                fun.drawBLine(dxf, Line42, 0.15, contour);
                Line Line43 = new Line(v1, v43);
                Line Line44 = new Line(v1, v44);
                Vector2[] Line55 = { v80, v81 };
                fun.drawBLine(dxf, Line55, 0.3, contour);
                Vector2[] Line56 = { v82, v8 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v83, v11 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                Line Line58 = new Line(v89, v87);
                LwPolyline Arc3 = new LwPolyline();
                Arc3.Vertexes.Add(new LwPolylineVertex(v87));
                Arc3.Vertexes.Add(new LwPolylineVertex(v86));
                Arc3.Vertexes[0].Bulge = (v87.X - v2.X) / (v87.Y - v86.Y) * 2;
                //fun.PolyFill(dxf, Arc3, 0.1, contour);
                Arc3.Layer = contour;
                dxf.AddEntity(Arc3);
                List<Vector3> point1 = new List<Vector3>
            {
                fun.Tothree(v86),
                fun.Tothree(v90),
                fun.Tothree(v88),
                fun.Tothree(v91),
                fun.Tothree(v87),
            };
                Spline spline1 = new Spline(point1);
                spline1.Layer = contour;
                dxf.AddEntity(spline1);
                Line Line59 = new Line(v86, v92);
                LwPolyline Arc6 = new LwPolyline();
                Arc6.Vertexes.Add(new LwPolylineVertex(v85));
                Arc6.Vertexes.Add(new LwPolylineVertex(v84));
                Arc6.Vertexes[0].Bulge = h / cl;
                Arc6.Layer = contour;
                dxf.AddEntity(Arc6);
                Line Line60 = new Line(v85, v93);
                LwPolyline Arc7 = new LwPolyline();
                Arc7.Vertexes.Add(new LwPolylineVertex(v95));
                Arc7.Vertexes.Add(new LwPolylineVertex(v96));
                Arc7.Vertexes[0].Bulge = cr * (1 - Math.Sin(60 * pi / 180)) / (cr / 2);
                Arc7.Layer = contour;
                dxf.AddEntity(Arc7);
                Line Line61 = new Line(v88, v95);
                LwPolyline Arc8 = new LwPolyline();
                Arc8.Vertexes.Add(new LwPolylineVertex(v98));
                Arc8.Vertexes.Add(new LwPolylineVertex(v97));
                Arc8.Vertexes[0].Bulge = cr * (1 - Math.Sin(60 * pi / 180)) / (cr / 2);
                Arc8.Layer = contour;
                dxf.AddEntity(Arc8);
                Line Line62 = new Line(v85, v97);
                Vector2[] Line63 = { new Vector2(v4.X, v95.Y), new Vector2(v4.X, v97.Y) };
                fun.drawBLine(dxf, Line63, 0.3, contour);
                Vector2[] Line64 = { new Vector2(v5.X, v95.Y), new Vector2(v5.X, v97.Y) };
                fun.drawBLine(dxf, Line64, 0.3, contour);
                //柄方
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v47));
                poly1.Vertexes.Add(new LwPolylineVertex(v49));
                poly1.Vertexes.Add(new LwPolylineVertex(v50));
                poly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v52));
                poly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v53));
                poly1.Vertexes.Add(new LwPolylineVertex(v55));
                poly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                poly1.Vertexes.Add(new LwPolylineVertex(v56));
                poly1.Vertexes.Add(new LwPolylineVertex(v46));
                poly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.3, contour);
                Line Line53 = new Line(v57, v58);
                Line Line54 = new Line(v59, v60);
                //主视图图层
                Line43.Layer = dimensioning;
                Line44.Layer = dimensioning;
                Line58.Layer = contour;
                Line59.Layer = contour;
                Line60.Layer = contour;
                Line61.Layer = contour;
                Line62.Layer = contour;
                //柄方图层
                Line53.Layer = centre;
                Line54.Layer = centre;
                Line53.Linetype = Linetype.Center;
                Line54.Linetype = Linetype.Center;
                //主视图
                dxf.AddEntity(Line43);
                dxf.AddEntity(Line44);
                dxf.AddEntity(Line58);
                dxf.AddEntity(Line59);
                dxf.AddEntity(Line60);
                dxf.AddEntity(Line61);
                dxf.AddEntity(Line62);
                //柄方
                dxf.AddEntity(Line53);
                dxf.AddEntity(Line54);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.5 * (oal / 40);
                dimensionStyle.ExtLineExtend = 0.6 * (oal / 40);//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                double height = (2.5 * (oal / 40)) / 2.0;
                double arrowsize = 0.5 * (oal / 40);
                //文本样式
                dimensionStyle.TextHeight = (2.5 * (oal / 40)) / 4.0;
                double offset = 20 * (oal / 40);
                //线段尺寸标注
                //尺寸1
                /*
                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v1, v43), new Line(v1, v44), offset, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);*/

                //  fun.jdbz2(dxf, new Line(v1, v43), new Line(v1, v44), offset /2.0, height , arrowsize , 0.4, "SIG = " + Math.Round(sig / (pi / 180), 2) + "°", "", "");
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v3, v16), -v3.X + v43.X - offset - 5, 270, dimensionStyle);
                dim2.UserText = "TD = " + Math.Round(lu / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                double toh = Convert.ToDouble(data["thltctrh"]);
                double tol = Convert.ToDouble(data["thltctrl"]);
                if (toh == 0 && tol == 0)
                {
                    LinearDimension dim3 = new LinearDimension(new Line(v17, v15), -offset * (2 / 3.0), 0, dimensionStyle);
                    dim3.UserText = "THL = " + Math.Round(thl / scale, 2);
                    dxf.AddEntity(dim3);
                }
                else
                {
                    fun.dimrot(dxf, v17, v15, 0, -offset * (2 / 3.0), 2.5, 2, 2.5, "THL = " + Math.Round(thl / scale, 2), toh + "", tol + "");
                }
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v17, v13), (-offset - 5) / 3.0, 0, dimensionStyle);
                dim4.UserText = "LU = " + Math.Round(lu / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                double toh1 = Convert.ToDouble(data["oaltctrh"]);
                double tol1 = Convert.ToDouble(data["oaltctrl"]);
                string oaltctr = Convert.ToString(data["oaltctr"]);
                if (toh1 == 0 && tol1 == 0)
                {
                    if (oaltctr.Equals("0"))
                    {
                        LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset, 0, dimensionStyle);
                        dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                        dxf.AddEntity(dim5);
                    }
                    else
                    {
                        LinearDimension dim7 = new LinearDimension(new Line(v17, v10), -offset, 0, dimensionStyle);
                        dim7.UserText = "OAL = " + Math.Round(oal / scale, 2) + "  " + oaltctr;
                        dxf.AddEntity(dim7);
                    }
                }
                else
                {
                    fun.dimrot(dxf, v17, v10, 0, -offset * 2, height, arrowsize, 2.5, "OAL = " + Math.Round(oal / scale, 2), toh1 + "", tol1 + "");
                }
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v23, v26), (-offset - (v26.Y - v11.Y)) / 3.0, 0, dimensionStyle);
                dim6.UserText = "DRVL = " + Math.Round(drvl / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                string tcdconws = Convert.ToString(data["tcdconws"]);
                if (tcdconws.Equals("0"))
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v80, v81), (v9.X - v80.X + offset) / 2.0, 270, dimensionStyle);
                    dim7.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                    dxf.AddEntity(dim7);
                }
                else
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v80, v81), (v9.X - v80.X + offset) / 2.0, 270, dimensionStyle);
                    dim7.UserText = "DMM = " + Math.Round(dmm / scale, 2) + "  " + tcdconws;
                    dxf.AddEntity(dim7);
                }

                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v46, v50), -offset / 2.0, 135, dimensionStyle);
                dim8.UserText = "DRVSC = " + Math.Round(drvsc / scale, 2);
                dxf.AddEntity(dim8);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
                hatchpoly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
                hatchpoly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
                hatchpoly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
                hatchpoly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 89, 2.5 * (td / 3.0), hline1, harc1, hatching);

                string l5;
                string kr;

                if (mc == 0) { l5 = "8P"; kr = "4°30′"; }
                else if (mc == 1) { l5 = "4P"; kr = "8°30′"; }
                else if (mc == 2) { l5 = "2P"; kr = "17°"; }
                else if (mc == 3) { l5 = "6P"; kr = "6°"; }
                else { l5 = ""; kr = ""; }

                if (mc == 3 && tp > 2.5)
                {
                    Line line01 = new Line(fun.Polar(v80, pi, 4), fun.Polar(v81, pi, 4)); fun.drawBline(dxf, line01, 0.3, contour);
                }
                if (mc == 1 && tp > 2.5)
                {
                    Line line01 = new Line(fun.Polar(v80, pi, 4), fun.Polar(v81, pi, 4)); fun.drawBline(dxf, line01, 0.3, contour);
                    Line line02 = new Line(fun.Polar(v80, pi, 6.5), fun.Polar(v81, pi, 6.5)); fun.drawBline(dxf, line02, 0.3, contour);
                }


                LinearDimension dim00 = new LinearDimension(new Line(v3, v2), offset, 0, dimensionStyle);
                dim00.UserText = "TCL = " + l5;
                dxf.AddEntity(dim00);

                fun.jdbz2(dxf, new Line(v3, v4), new Line(v2, v3), offset, height, arrowsize, 0.6, "KAPR=" + kr, "", "");

                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v1.X - 210 + (v45.X + v8.Y - v1.X) / 2.00, v1.Y + 148.5), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Nuttaps(Dictionary<string, Object> data)//螺母丝锥
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double td = Convert.ToDouble(data["td"]);
            double tp = Convert.ToDouble(data["tp"]);
            double oal = Convert.ToDouble(data["oal"]);
            double thl = Convert.ToDouble(data["thl"]);
            double tcl = Convert.ToDouble(data["tcl"]);
            double dmm = Convert.ToDouble(data["dconms"]);
            double angular = Convert.ToDouble(data["angular"]);
            double waidingjian = Convert.ToDouble(data["waidingjian"]);
            double drvsc = Convert.ToDouble(data["drvsc"]);
            double drvl = Convert.ToDouble(data["drvl"]);

            /*double td = 20;
            double tp = 1.5;
            double oal = 220;
            double thl = 50;
            double tcl = 24;
            double dmm = 16;
            double angular = 2;
            double waidingjian = 0;
            double drvsc = 16;
            double drvl = 20;*/





            Vector2 v0 = new Vector2(0, 0);
            Vector2 v1 = fun.Polar(v0, 90 * pi / 180, td / 2);
            Vector2 v2 = fun.Polar(v0, pi, tcl);
            Vector2 v3 = fun.Polar(v0, 90 * pi / 180, dmm / 4);
            Vector2 v4 = fun.Inters(v1, fun.Polar(v1, (180 + angular) * pi / 180, 1), v2, fun.Polar(v2, 90 * pi / 180, 1));
            Vector2 v5 = new Vector2(v2.X, v3.Y);
            Vector2 v7 = fun.Inters(v4, fun.Polar(v4, -145 * pi / 180, 1), v2, v0);
            Vector2 v11 = fun.Polar(v5, 0, thl);
            Vector2 v8 = fun.Inters(v4, v1, v11, fun.Polar(v11, 90 * pi / 180, 1));
            Vector2 v16 = new Vector2(v2.X + oal, v0.Y + dmm / 2);
            Vector2 v10 = fun.Inters(v8, fun.Polar(v8, -45 * pi / 180, 1), v16, fun.Polar(v16, pi, 1));
            Vector2 v9 = fun.Polar(v8, -45 * pi / 180, fun.CalDistance(v8, v10) / 5 * 3);
            Vector2 v12 = new Vector2(v10.X, v3.Y);
            Vector2 v13 = fun.Inters(v1, v4, v9, fun.Polar(v9, pi, 1));
            Vector2 v14 = fun.Polar(v12, 0, (v8.Y - v0.Y));
            Vector2 v15 = new Vector2(v14.X, v16.Y);
            Vector2 v17 = fun.Inters(v16, fun.Polar(v16, -35 * pi / 180, 1), v2, v0);
            Vector2 a1 = new Vector2(v1.X, -v1.Y);
            Vector2 a2 = new Vector2(v2.X, -v2.Y);
            Vector2 a3 = new Vector2(v3.X, -v3.Y);
            Vector2 a4 = new Vector2(v4.X, -v4.Y);
            Vector2 a5 = new Vector2(v5.X, -v5.Y);
            Vector2 a8 = new Vector2(v8.X, -v8.Y);
            Vector2 a9 = new Vector2(v9.X, -v9.Y);
            Vector2 a10 = new Vector2(v10.X, -v10.Y);
            Vector2 a11 = new Vector2(v11.X, -v11.Y);
            Vector2 a12 = new Vector2(v12.X, -v12.Y);
            Vector2 a13 = new Vector2(v13.X, -v13.Y);
            Vector2 a14 = new Vector2(v14.X, -v14.Y);
            Vector2 a15 = new Vector2(v15.X, -v15.Y);
            Vector2 a16 = new Vector2(v16.X, -v16.Y);

            string tctr = Convert.ToString(data["tctr"]);
            //string tctr = "0";
            if (!tctr.Equals("0"))
            {
                Vector2 a01 = fun.Polar(v4, fun.CalAngle(v4, v8), fun.CalDistance(v4, v8) / 2);
                Vector2 a02 = fun.Polar(a01, 45 * pi / 180, 15);
                Vector2 a03 = fun.Polar(a01, 45 * pi / 180, 16);
                Line line101 = new Line(a01, a02);
                dxf.AddEntity(line101);
                fun.text(dxf, a03, 2, "丝锥公差带:" + tctr + "");

            }

            LwPolyline poly00 = new LwPolyline();
            poly00.Vertexes.Add(new LwPolylineVertex(v4));
            poly00.Vertexes.Add(new LwPolylineVertex(v8));
            poly00.Vertexes.Add(new LwPolylineVertex(v10));
            poly00.Vertexes.Add(new LwPolylineVertex(v16));
            fun.PolyFill(dxf, poly00, 0.3, contour);
            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(a16));
            poly1.Vertexes.Add(new LwPolylineVertex(a10));
            poly1.Vertexes.Add(new LwPolylineVertex(a8));
            poly1.Vertexes.Add(new LwPolylineVertex(a4));
            fun.PolyFill(dxf, poly1, 0.3, contour);
            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(v5));
            poly2.Vertexes.Add(new LwPolylineVertex(v14));
            poly2.Vertexes.Add(new LwPolylineVertex(v15));
            poly2.Vertexes[1].Bulge = -Math.Tan(-150 * pi / 180 / 4);
            fun.PolyFill(dxf, poly2, 0.3, contour);
            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(a5));
            poly3.Vertexes.Add(new LwPolylineVertex(a14));
            poly3.Vertexes.Add(new LwPolylineVertex(a15));
            poly3.Vertexes[1].Bulge = -Math.Tan(150 * pi / 180 / 4);
            fun.PolyFill(dxf, poly3, 0.3, contour);
            Vector2[] Line4 = { v3, a3 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v11, a11 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v12, a12 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Line line7 = new Line(v9, v13);
            line7.Lineweight = Lineweight.W25;
            line7.Layer = additionalline;
            dxf.AddEntity(line7);
            Line line8 = new Line(a9, a13);
            line8.Lineweight = Lineweight.W25;
            line8.Layer = additionalline;
            dxf.AddEntity(line8);

            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 1;
            dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1;
            double offset = 20;

            LinearDimension dim1 = new LinearDimension(new Line(v1, a1), thl + 10, 90, dimensionStyle);
            dim1.UserText = "TD = " + td;
            dxf.AddEntity(dim1);
            LinearDimension dim2 = new LinearDimension(new Line(a4, a3), offset * 0.5, 180, dimensionStyle);
            dim2.UserText = "TCL = " + tcl;
            dxf.AddEntity(dim2);

            double toh = Convert.ToDouble(data["thltctrh"]);
            double tol = Convert.ToDouble(data["thltctrl"]);
            //double toh = 0;
            //double tol = 0;
            if (toh == 0 && tol == 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(a4, a11), offset, 180, dimensionStyle);
                dim3.UserText = "THL = " + thl;
                dxf.AddEntity(dim3);
            }
            else
            {
                fun.dimrot(dxf, a4, a11, 0, -offset, 1, 2, -1, "THL = " + thl, toh + "", tol + "");
            }
            double toh1 = Convert.ToDouble(data["oaltctrh"]);
            double tol1 = Convert.ToDouble(data["oaltctrl"]);
            string oaltctr = Convert.ToString(data["oaltctr"]);
            /*double toh1 = 0;
            double tol1 =0;
            string oaltctr = "0";*/
            if (toh1 == 0 && tol1 == 0)
            {
                if (oaltctr.Equals("0"))
                {

                    LinearDimension dim4 = new LinearDimension(new Line(a4, a16), offset * 1.5, 180, dimensionStyle);
                    dim4.UserText = "OAL = " + oal;
                    dxf.AddEntity(dim4);
                }
                else
                {
                    LinearDimension dim4 = new LinearDimension(new Line(a4, a16), offset * 1.5, 180, dimensionStyle);
                    dim4.UserText = "OAL = " + oal + "  " + oaltctr;
                    dxf.AddEntity(dim4);
                }

            }
            else
            {
                fun.dimrot(dxf, a4, a16, 0, -offset * 1.5, 1, 2, -1, "OAL = " + oal, toh1 + "", tol1 + "");
            }

            string tcdconws = Convert.ToString(data["tcdconws"]);
            //string tcdconws = "0";
            if (tcdconws.Equals("0"))
            {
                LinearDimension dim5 = new LinearDimension(new Line(a16, v16), offset * 0.5, 90, dimensionStyle);
                dim5.UserText = "DCONMS = " + dmm;
                dxf.AddEntity(dim5);
            }
            else
            {
                LinearDimension dim5 = new LinearDimension(new Line(a16, v16), offset * 0.5, 90, dimensionStyle);
                dim5.UserText = "DCONMS = " + dmm + "  " + tcdconws;
                dxf.AddEntity(dim5);
            }





            if (td <= 10 && waidingjian == 1 && drvsc == 0)
            {

                Vector2 v18 = fun.Polar(v7, pi, dmm / 2);
                Vector2 v19 = fun.Polar(v17, 0, dmm / 2);

                LwPolyline poly7 = new LwPolyline();
                poly7.Vertexes.Add(new LwPolylineVertex(v4));
                poly7.Vertexes.Add(new LwPolylineVertex(v7));
                poly7.Vertexes.Add(new LwPolylineVertex(a4));
                poly7.Vertexes.Add(new LwPolylineVertex(a5));
                poly7.Vertexes[2].Bulge = -Math.Tan(-50 * pi / 180 / 4);
                poly7.Vertexes.Add(new LwPolylineVertex(v5));
                poly7.Vertexes.Add(new LwPolylineVertex(v4));
                poly7.Vertexes[4].Bulge = -Math.Tan(-50 * pi / 180 / 4);
                fun.PolyFill(dxf, poly7, 0.3, contour);

                LwPolyline poly8 = new LwPolyline();
                poly8.Vertexes.Add(new LwPolylineVertex(v16));
                poly8.Vertexes.Add(new LwPolylineVertex(v17));
                poly8.Vertexes.Add(new LwPolylineVertex(a16));
                poly8.Vertexes.Add(new LwPolylineVertex(v16));
                fun.PolyFill(dxf, poly8, 0.3, contour);


                Vector2[] Line9 = { v19, v18 };
                fun.drawPlinetype(dxf, Line9, 0.15, centre, Linetype.Center);

            }
            if (td > 5 && drvsc != 0)
            {
                Vector2 v18 = fun.Polar(v2, pi, dmm / 2);
                Vector2 v19 = fun.Polar(new Vector2(v16.X, v0.Y), 0, dmm / 2);
                Vector2 v20 = fun.Polar(v16, -90 * pi / 180, dmm / 3);
                Vector2 v21 = fun.Polar(v20, pi, drvl);
                Vector2 v22 = new Vector2(v21.X, v16.Y);
                Vector2 a20 = new Vector2(v20.X, -v20.Y);
                Vector2 a21 = new Vector2(v21.X, -v21.Y);
                Vector2 a22 = new Vector2(v22.X, -v22.Y);


                Vector2 v019 = fun.Polar(v19, 0, drvsc * 3);
                Vector2 v020 = fun.Polar(v019, 90 * pi / 180, drvsc);
                Vector2 v021 = fun.Polar(v019, 0, drvsc);
                Vector2 v022 = fun.Polar(v019, pi, drvsc);
                Vector2 v023 = fun.Polar(v019, -90 * pi / 180, drvsc);
                Vector2 v020p = fun.Polar(v019, 90 * pi / 180, drvsc * Math.Sin(45 * pi / 180));
                Vector2 v021p = fun.Polar(v019, 0, drvsc * Math.Sin(45 * pi / 180));
                Vector2 v022p = fun.Polar(v019, pi, drvsc * Math.Sin(45 * pi / 180));
                Vector2 v023p = fun.Polar(v019, -90 * pi / 180, drvsc * Math.Sin(45 * pi / 180));
                Vector2 v024 = fun.Polar(v020p, -135 * pi / 180, drvsc / 5);
                Vector2 v025 = fun.Polar(v020p, -45 * pi / 180, drvsc / 5);
                Vector2 v026 = fun.Polar(v021p, 135 * pi / 180, drvsc / 5);
                Vector2 v027 = fun.Polar(v021p, -135 * pi / 180, drvsc / 5);
                Vector2 v028 = fun.Polar(v023p, 45 * pi / 180, drvsc / 5);
                Vector2 v029 = fun.Polar(v023p, 135 * pi / 180, drvsc / 5);
                Vector2 v030 = fun.Polar(v022p, -45 * pi / 180, drvsc / 5);
                Vector2 v031 = fun.Polar(v022p, 45 * pi / 180, drvsc / 5);


                LwPolyline poly7 = new LwPolyline();
                poly7.Vertexes.Add(new LwPolylineVertex(v4));
                poly7.Vertexes.Add(new LwPolylineVertex(a4));
                fun.PolyFill(dxf, poly7, 0.3, contour);

                Vector2[] Line9 = { v16, a16 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v20, v21 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v21, v22 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { a20, a21 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { a21, a22 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v19, v18 };
                fun.drawPlinetype(dxf, Line14, 0.15, centre, Linetype.Center);
                Vector2[] Line15 = { v020, v023 };
                fun.drawPlinetype(dxf, Line15, 0.15, centre, Linetype.Center);
                Vector2[] Line16 = { v022, v021 };
                fun.drawPlinetype(dxf, Line16, 0.15, centre, Linetype.Center);

                LwPolyline poly8 = new LwPolyline();
                poly8.Vertexes.Add(new LwPolylineVertex(v031));
                poly8.Vertexes.Add(new LwPolylineVertex(v024));
                poly8.Vertexes.Add(new LwPolylineVertex(v025));
                poly8.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                poly8.Vertexes.Add(new LwPolylineVertex(v026));
                poly8.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                poly8.Vertexes.Add(new LwPolylineVertex(v027));
                poly8.Vertexes.Add(new LwPolylineVertex(v028));
                poly8.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                poly8.Vertexes.Add(new LwPolylineVertex(v029));
                poly8.Vertexes.Add(new LwPolylineVertex(v030));
                poly8.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                poly8.IsClosed = true;
                fun.PolyFill(dxf, poly8, 0.3, contour);

                LwPolyline poly9 = new LwPolyline();
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = poly8.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = poly8.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)poly8.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)poly8.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);


                LinearDimension dim10 = new LinearDimension(new Line(v029, v026), offset, -135, dimensionStyle);
                dim10.UserText = "DRVSC = " + drvsc;
                dxf.AddEntity(dim10);

                LinearDimension dim11 = new LinearDimension(new Line(a20, a21), offset, 180, dimensionStyle);
                dim11.UserText = "DRVL = " + drvl;
                dxf.AddEntity(dim11);


            }
            else
            {

                Vector2 v18 = fun.Polar(v2, pi, dmm / 2);
                Vector2 v19 = fun.Polar(new Vector2(v16.X, v0.Y), 0, dmm / 2);
                Vector2[] Line9 = { v4, a4 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v16, a16 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line14 = { v19, v18 };
                fun.drawPlinetype(dxf, Line14, 0.15, centre, Linetype.Center);

            }

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void Trapezoidalthreadtaps(Dictionary<string, Object> data)//梯形螺纹丝锥
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double pi = Math.PI;
            double td = Convert.ToDouble(data["td"]);
            double tp = Convert.ToDouble(data["tp"]);
            double oal = Convert.ToDouble(data["oal"]);
            double thl = Convert.ToDouble(data["thl"]);
            double lu = Convert.ToDouble(data["lu"]);
            if (lu == 0)
            {
                lu = thl * 39 / 22;
            }
            double l3 = Convert.ToDouble(data["tcl"]);
            double l4 = l3 * 1 / 5;
            double tcpd = Convert.ToDouble(data["tcpd"]);
            double dmm = Convert.ToDouble(data["dconms"]);
            double drvsc = Convert.ToDouble(data["drvsc"]);
            double drvl = Convert.ToDouble(data["drvl"]);
            string path = Convert.ToString(data["path"]);

            Vector2 v1 = new Vector2(0, 0);
            Vector2 v3 = new Vector2(v1.X + 0.5, v1.Y + tcpd / 2);
            Vector2 v2 = fun.Inters(v1, fun.Polar(v1, 90 * pi / 180, 1), v3, fun.Polar(v3, -135 * pi / 180, 1));
            Vector2 v4 = new Vector2(v1.X + l3 - l4, v3.Y);
            Vector2 v5 = fun.Polar(v4, -90 * pi / 180, l4);
            Vector2 v6 = fun.Polar(v5, 0, l4);
            Vector2 v7 = new Vector2(v6.X, v4.Y);
            Vector2 v8 = new Vector2(v7.X + thl, v1.Y + td / 2);
            Vector2 v9 = new Vector2(v7.X + lu, v1.Y + td / 2);
            Vector2 v11 = new Vector2(v9.X, v1.Y + dmm / 2);
            Vector2 v10 = fun.Polar(v9, -90 * pi / 180, (v9.Y - v11.Y) / 2);
            Vector2 v10p = fun.Inters(v10, fun.Polar(v10, pi, 1), v7, v8);
            Vector2 v12 = new Vector2(v1.X + oal - (3 * dmm / 16), v11.Y);
            Vector2 v13 = new Vector2(v1.X + oal, v1.Y + dmm / 2 - 3 * dmm / 8 / 2);
            Vector2 v16 = fun.Polar(v12, -90 * pi / 180, 3 * dmm / 8);
            Vector2 v14 = new Vector2(v13.X - drvl, v12.Y);
            Vector2 v15 = new Vector2(v14.X, v16.Y);
            Vector2 v17 = fun.Polar(v1, 180 * pi / 180, 5);
            Vector2 v18 = new Vector2(v13.X + 5, v1.Y);
            Vector2 a2 = new Vector2(v2.X, -v2.Y);
            Vector2 a3 = new Vector2(v3.X, -v3.Y);
            Vector2 a4 = new Vector2(v4.X, -v4.Y);
            Vector2 a5 = new Vector2(v5.X, -v5.Y);
            Vector2 a6 = new Vector2(v6.X, -v6.Y);
            Vector2 a7 = new Vector2(v7.X, -v7.Y);
            Vector2 a8 = new Vector2(v8.X, -v8.Y);
            Vector2 a9 = new Vector2(v9.X, -v9.Y);
            Vector2 a10 = new Vector2(v10.X, -v10.Y);
            Vector2 a10p = new Vector2(v10p.X, -v10p.Y);
            Vector2 a11 = new Vector2(v11.X, -v11.Y);
            Vector2 a12 = new Vector2(v12.X, -v12.Y);
            Vector2 a13 = new Vector2(v13.X, -v13.Y);
            Vector2 a14 = new Vector2(v14.X, -v14.Y);
            Vector2 a15 = new Vector2(v15.X, -v15.Y);
            Vector2 a16 = new Vector2(v16.X, -v16.Y);
            Vector2 v19 = fun.Polar(v18, 0, drvsc * 3);
            Vector2 v20 = fun.Polar(v19, 90 * pi / 180, drvsc);
            Vector2 v21 = fun.Polar(v19, 0, drvsc);
            Vector2 v22 = fun.Polar(v19, pi, drvsc);
            Vector2 v23 = fun.Polar(v19, -90 * pi / 180, drvsc);
            Vector2 v20p = fun.Polar(v19, 90 * pi / 180, drvsc * Math.Sin(45 * pi / 180));
            Vector2 v21p = fun.Polar(v19, 0, drvsc * Math.Sin(45 * pi / 180));
            Vector2 v22p = fun.Polar(v19, pi, drvsc * Math.Sin(45 * pi / 180));
            Vector2 v23p = fun.Polar(v19, -90 * pi / 180, drvsc * Math.Sin(45 * pi / 180));
            Vector2 v24 = fun.Polar(v20p, -135 * pi / 180, drvsc / 5);
            Vector2 v25 = fun.Polar(v20p, -45 * pi / 180, drvsc / 5);
            Vector2 v26 = fun.Polar(v21p, 135 * pi / 180, drvsc / 5);
            Vector2 v27 = fun.Polar(v21p, -135 * pi / 180, drvsc / 5);
            Vector2 v28 = fun.Polar(v23p, 45 * pi / 180, drvsc / 5);
            Vector2 v29 = fun.Polar(v23p, 135 * pi / 180, drvsc / 5);
            Vector2 v30 = fun.Polar(v22p, -45 * pi / 180, drvsc / 5);
            Vector2 v31 = fun.Polar(v22p, 45 * pi / 180, drvsc / 5);

            string tctr = Convert.ToString(data["tctr"]);
            if (!tctr.Equals("0"))
            {
                Vector2 a01 = fun.Polar(v7, fun.CalAngle(v7, v8), fun.CalDistance(v7, v8) / 2);
                Vector2 a02 = fun.Polar(a01, 45 * pi / 180, 15);
                Vector2 a03 = fun.Polar(a01, 45 * pi / 180, 16);
                Line line101 = new Line(a01, a02);
                dxf.AddEntity(line101);
                fun.text(dxf, a03, 2, "丝锥公差带:" + tctr + "");

            }

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(v1));
            poly1.Vertexes.Add(new LwPolylineVertex(v2));
            poly1.Vertexes.Add(new LwPolylineVertex(v3));
            poly1.Vertexes[1].Bulge = -Math.Tan(90 * pi / 180 / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(v4));
            poly1.Vertexes.Add(new LwPolylineVertex(v5));
            poly1.Vertexes.Add(new LwPolylineVertex(v6));
            poly1.Vertexes.Add(new LwPolylineVertex(v7));
            poly1.Vertexes.Add(new LwPolylineVertex(v8));
            poly1.Vertexes.Add(new LwPolylineVertex(v9));
            poly1.Vertexes.Add(new LwPolylineVertex(v10));
            poly1.Vertexes.Add(new LwPolylineVertex(v11));
            poly1.Vertexes.Add(new LwPolylineVertex(v12));
            poly1.Vertexes.Add(new LwPolylineVertex(v16));
            poly1.Vertexes[11].Bulge = -Math.Tan(180 * pi / 180 / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(a16));
            poly1.Vertexes.Add(new LwPolylineVertex(a12));
            poly1.Vertexes[13].Bulge = -Math.Tan(180 * pi / 180 / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(a11));
            poly1.Vertexes.Add(new LwPolylineVertex(a10));
            poly1.Vertexes.Add(new LwPolylineVertex(a9));
            poly1.Vertexes.Add(new LwPolylineVertex(a8));
            poly1.Vertexes.Add(new LwPolylineVertex(a7));
            poly1.Vertexes.Add(new LwPolylineVertex(a6));
            poly1.Vertexes.Add(new LwPolylineVertex(a5));
            poly1.Vertexes.Add(new LwPolylineVertex(a4));
            poly1.Vertexes.Add(new LwPolylineVertex(a3));
            poly1.Vertexes.Add(new LwPolylineVertex(a2));
            poly1.Vertexes[23].Bulge = -Math.Tan(90 * pi / 180 / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(v1));
            poly1.IsClosed = true;
            fun.PolyFill(dxf, poly1, 0.3, contour);
            Vector2[] Line1 = { v3, a3 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v5, a5 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v8, a8 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v11, a11 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v14, v15 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v15, v16 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { a14, a15 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { a15, a16 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { a13, v13 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { a6, v6 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Line line11 = new Line(a10, a10p);
            line11.Lineweight = Lineweight.W25;
            line11.Layer = additionalline;
            dxf.AddEntity(line11);
            Line line12 = new Line(v10, v10p);
            line12.Lineweight = Lineweight.W25;
            line12.Layer = additionalline;
            dxf.AddEntity(line12);
            Vector2[] Line13 = { v17, v18 };
            fun.drawPlinetype(dxf, Line13, 0.15, centre, Linetype.Center);
            Vector2[] Line14 = { v22, v21 };
            fun.drawPlinetype(dxf, Line14, 0.15, centre, Linetype.Center);
            Vector2[] Line15 = { v20, v23 };
            fun.drawPlinetype(dxf, Line15, 0.15, centre, Linetype.Center);
            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(v31));
            poly2.Vertexes.Add(new LwPolylineVertex(v24));
            poly2.Vertexes.Add(new LwPolylineVertex(v25));
            poly2.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            poly2.Vertexes.Add(new LwPolylineVertex(v26));
            poly2.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            poly2.Vertexes.Add(new LwPolylineVertex(v27));
            poly2.Vertexes.Add(new LwPolylineVertex(v28));
            poly2.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            poly2.Vertexes.Add(new LwPolylineVertex(v29));
            poly2.Vertexes.Add(new LwPolylineVertex(v30));
            poly2.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            poly2.IsClosed = true;
            fun.PolyFill(dxf, poly2, 0.3, contour);
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = poly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = poly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)poly2.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)poly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 89, 5, hline1, harc1, hatching);



            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 1;
            dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1;
            double offset = 20;

            LinearDimension dim1 = new LinearDimension(new Line(v3, a3), offset, 90, dimensionStyle);
            dim1.UserText = "GPD = " + tcpd;
            dxf.AddEntity(dim1);
            LinearDimension dim2 = new LinearDimension(new Line(v2, v7), offset, 0, dimensionStyle);
            dim2.UserText = "L3 = " + l3;
            dxf.AddEntity(dim2);
            LinearDimension dim3 = new LinearDimension(new Line(v4, v7), offset / 2, 0, dimensionStyle);
            dim3.UserText = "L4空刀尺寸不作规范";
            dxf.AddEntity(dim3);
            double toh1 = Convert.ToDouble(data["oaltctrh"]);
            double tol1 = Convert.ToDouble(data["oaltctrl"]);
            string oaltctr = Convert.ToString(data["oaltctr"]);
            if (toh1 == 0 && tol1 == 0)
            {
                if (oaltctr.Equals("0"))
                {
                    LinearDimension dim4 = new LinearDimension(new Line(a2, a13), offset, 180, dimensionStyle);
                    dim4.UserText = "OAL = " + oal;
                    dxf.AddEntity(dim4);
                }
                else
                {
                    LinearDimension dim4 = new LinearDimension(new Line(a2, a13), offset, 180, dimensionStyle);
                    dim4.UserText = "OAL = " + oal + "  " + oaltctr;
                    dxf.AddEntity(dim4);
                }


            }
            else
            {
                fun.dimrot(dxf, a2, a13, 0, -offset, 1.5, 2, 0, "OAL = " + oal, toh1 + "", tol1 + "");
            }


            LinearDimension dim5 = new LinearDimension(new Line(a7, a9), offset / 3 * 2, 180, dimensionStyle);
            dim5.UserText = "LU = " + lu;
            dxf.AddEntity(dim5);
            double toh = Convert.ToDouble(data["thltctrh"]);
            double tol = Convert.ToDouble(data["thltctrl"]);
            if (toh == 0 && tol == 0)
            {
                LinearDimension dim6 = new LinearDimension(new Line(a7, a8), offset / 3, 180, dimensionStyle);
                dim6.UserText = "THL = " + thl;
                dxf.AddEntity(dim6);
            }
            else
            {
                fun.dimrot(dxf, a7, a8, 0, -offset / 3, 1.5, 2, 0, "THL = " + thl, toh + "", tol + "");
            }
            LinearDimension dim7 = new LinearDimension(new Line(a14, a13), offset / 3, 180, dimensionStyle);
            dim7.UserText = "DRVL = " + drvl;
            dxf.AddEntity(dim7);
            LinearDimension dim8 = new LinearDimension(new Line(v9, a9), offset / 5, 90, dimensionStyle);
            dim8.UserText = "TD = " + td;
            dxf.AddEntity(dim8);
            string tcdconws = Convert.ToString(data["tcdconws"]);
            if (tcdconws.Equals("0"))
            {
                LinearDimension dim9 = new LinearDimension(new Line(v14, a14), offset / 5, 90, dimensionStyle);
                dim9.UserText = "DCONMS = " + dmm;
                dxf.AddEntity(dim9);
            }
            else
            {
                LinearDimension dim9 = new LinearDimension(new Line(v14, a14), offset / 5, 90, dimensionStyle);
                dim9.UserText = "DCONMS = " + dmm + "  " + tcdconws;
                dxf.AddEntity(dim9);
            }

            LinearDimension dim10 = new LinearDimension(new Line(v29, v26), offset, -135, dimensionStyle);
            dim10.UserText = "DRVSC = " + drvsc;
            dxf.AddEntity(dim10);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void StraightFluteTap(Dictionary<string, Object> data)    //直槽带尖丝锥(粗柄)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 105)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 210)
            {
                scale = 1.0;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double td = Convert.ToDouble(data["td"]) * scale;
            double dmm = Convert.ToDouble(data["dconms"]) * scale;
            double tp = Convert.ToDouble(data["tp"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            if (dn == 0)
            {
                dn = td - 1.1325 * tp - 0.15;
            }

            double mc = Convert.ToDouble(data["mc"]);
            double qxzj;
            if (mc == 0)
            {
                qxzj = 4.5 * pi / 180;
            }
            if (mc == 1)
            {
                qxzj = 8.5 * pi / 180;
            }
            if (mc == 2)
            {
                qxzj = 17 * pi / 180;
            }
            else
            {
                qxzj = 6 * pi / 180;
            }

            double tcl;
            if (mc == 0)
            {
                tcl = 8 * tp;
            }
            else if (mc == 1)
            {
                tcl = 4 * tp;
            }
            else if (mc == 2)
            {
                tcl = 2 * tp;
            }
            else
            {
                tcl = 6 * tp;
            }

            if (tcl == 0)
            {
                tcl = tp * 2.3;
            }
            double tcpd = td - tcl * Math.Tan(qxzj);
            double wcf = Convert.ToDouble(data["wcf"]) * scale;
            if (wcf == 0)
            {
                wcf = td / 3;
            }
            double thl = Convert.ToDouble(data["thl"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;
            if (lu == 0)
            {
                lu = thl * 39 / 22;
            }
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
            double drvl = Convert.ToDouble(data["drvl"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double ta = Convert.ToDouble(data["ta"]) * pi / 180;
            double ds = dmm - 0.08 * scale;//柄方外圆
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v2 = new Vector2(-oal / 2.00, tcpd / 2.00);
            Vector2 v1 = new Vector2(v2.X - v2.Y / Math.Tan(sig / 2.00), 0);
            Vector2 v3 = new Vector2(v2.X + tcl, td / 2.00);
            Vector2 v4 = new Vector2(v2.X + thl, v3.Y);
            Vector2 v5 = new Vector2((td - dn) / 2.00 + v4.X, dn / 2.00);
            Vector2 v6 = new Vector2(v2.X + lu, v5.Y);
            Vector2 v7 = new Vector2((dmm - dn) / 2.00 / Math.Tan(ta) + v6.X, dmm / 2.00);
            Vector2 v8 = new Vector2(v2.X + oal - 0.15 * dmm, ds / 2);
            Vector2 v9 = new Vector2(v2.X + oal, 0.35 * dmm);
            Vector2 v10 = new Vector2(v9.X, -v9.Y);
            Vector2 v11 = new Vector2(v8.X, -v8.Y);
            Vector2 v12 = new Vector2(v7.X, -v7.Y);
            Vector2 v13 = new Vector2(v6.X, -v6.Y);
            Vector2 v14 = new Vector2(v5.X, -v5.Y);
            Vector2 v15 = new Vector2(v4.X, -v4.Y);
            Vector2 v16 = new Vector2(v3.X, -v3.Y);
            Vector2 v17 = new Vector2(v2.X, -v2.Y);
            Vector2 v19 = new Vector2(v8.X - drvl, ds / 2.00 * (Math.Sin(45 * pi / 180) * drvsc / ds - Math.Cos(45 * pi / 180) * Math.Sqrt(1 - (drvsc * drvsc) / (ds * ds))));
            Vector2 v18 = new Vector2(v19.X, drvsc * Math.Sin(45 * pi / 180) - v19.Y);
            Vector2 v20 = new Vector2(v8.X, v19.Y);
            Vector2 v21 = new Vector2(v20.X, v18.Y);
            Vector2 v22 = new Vector2(v21.X - (v18.Y - v19.Y) / 2.00 * Math.Tan(60 * pi / 180), (v18.Y + v19.Y) / 2.00);
            Vector2 v23 = new Vector2(v18.X, -v18.Y);
            Vector2 v24 = new Vector2(v19.X, -v19.Y);
            Vector2 v25 = new Vector2(v20.X, -v20.Y);
            Vector2 v26 = new Vector2(v21.X, -v21.Y);
            Vector2 v27 = new Vector2(v22.X, -v22.Y);
            Vector2 v28 = new Vector2(v2.X + lu - 3, 0);
            Vector2 v29 = new Vector2(v2.X + lu - 2 * wcf / 3.00 - 3, wcf / 3.00);
            Vector2 v30 = new Vector2(v2.X + lu - 3 * wcf / 2.00 - 3, wcf / 2.00);
            Vector2 v31 = new Vector2(v30.X, -v30.Y);
            Vector2 v32 = new Vector2(v29.X, -v29.Y);
            Vector2 v33 = new Vector2(v2.X, v30.Y);
            Vector2 v34 = new Vector2(v33.X, -v33.Y);
            double dx = v2.X;
            if (tcpd < dn)
            {
                dx = (v5.Y - oal * (td - tcpd) / 4 / tcl - tcpd / 2) * 2 * tcl / (td - tcpd);
            }
            Vector2 v35 = new Vector2(dx, v5.Y);
            Vector2 v36 = new Vector2(dx, v14.Y);
            Vector2 v37 = new Vector2(v4.X, v34.Y);
            Vector2 v38 = new Vector2(v37.X, -v37.Y);
            Vector2 v39 = new Vector2(v5.X, v38.Y);
            Vector2 v40 = new Vector2(v39.X, -v39.Y);
            Vector2 v41 = new Vector2(v1.X - 2, v1.Y);
            Vector2 v42 = new Vector2(v9.X + 2, v1.Y);
            Vector2 v43 = new Vector2(2 * v1.X - v17.X, v2.Y);
            Vector2 v44 = new Vector2(2 * v1.X - v2.X, v17.Y);
            Vector2 v80 = new Vector2(v8.X - drvl - 1 * scale, v7.Y);
            Vector2 v81 = new Vector2(v80.X, -v80.Y);
            Vector2 v82 = new Vector2(v80.X, ds / 2.00);
            Vector2 v83 = new Vector2(v82.X, -v82.Y);
            //柄方
            Vector2 v45 = new Vector2(105 + oal / 4.00, v8.Y - (v20.Y - v25.Y) * Math.Cos(45 * pi / 180));
            Vector2 v46 = new Vector2(v45.X - (v20.Y - v25.Y) / 2.00, v45.Y + (v20.Y - v25.Y) / 2.00);
            Vector2 v47 = new Vector2(v45.X * 2 - v46.X, v46.Y);
            Vector2 v48 = new Vector2(v45.X + v45.Y, v1.Y);
            Vector2 v49 = new Vector2(v45.X + v46.Y, v48.Y + v47.X - v45.X);
            Vector2 v50 = new Vector2(v49.X, -v49.Y);
            Vector2 v51 = new Vector2(v45.X, -v45.Y);
            Vector2 v52 = new Vector2(v47.X, -v47.Y);
            Vector2 v53 = new Vector2(v46.X, -v46.Y);
            Vector2 v54 = new Vector2(v45.X * 2 - v48.X, v48.Y);
            Vector2 v55 = new Vector2(v45.X * 2 - v50.X, v50.Y);
            Vector2 v56 = new Vector2(v45.X * 2 - v49.X, v49.Y);
            Vector2 v57 = new Vector2(v45.X - ds / 2.00 - 2, 0);
            Vector2 v58 = new Vector2(v45.X + ds / 2.00 + 2, 0);
            Vector2 v59 = new Vector2(v45.X, ds / 2.00 + 2);
            Vector2 v60 = new Vector2(v59.X, -v59.Y);
            string tctr = Convert.ToString(data["tctr"]);
            if (!tctr.Equals("0"))
            {
                Vector2 a1 = fun.Polar(v3, fun.CalAngle(v3, v4), fun.CalDistance(v3, v4) / 2);
                Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                Line line101 = new Line(a1, a2);
                dxf.AddEntity(line101);
                fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

            }
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v80 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v81, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v1 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v2, v17 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v4, v38 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v37, v15 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v5, v39 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v40, v14 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v6, v13 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v7, v12 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v8, v21 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { v20, v25 };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            Vector2[] Line27 = { v26, v11 };
            fun.drawBLine(dxf, Line27, 0.3, contour);
            Vector2[] Line28 = { v21, v18 };
            fun.drawBLine(dxf, Line28, 0.3, contour);
            Vector2[] Line29 = { v18, v19 };
            fun.drawBLine(dxf, Line29, 0.3, contour);
            Vector2[] Line30 = { v19, v20 };
            fun.drawBLine(dxf, Line30, 0.3, contour);
            Vector2[] Line31 = { v25, v24 };
            fun.drawBLine(dxf, Line31, 0.3, contour);
            Vector2[] Line32 = { v24, v23 };
            fun.drawBLine(dxf, Line32, 0.3, contour);
            Vector2[] Line33 = { v23, v26 };
            fun.drawBLine(dxf, Line33, 0.3, contour);
            //Arc Arc1 = new Arc(v22, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
            //Arc Arc2 = new Arc(v27, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
            LwPolyline Arc1 = new LwPolyline();
            Arc1.Vertexes.Add(new LwPolylineVertex(v21));
            Arc1.Vertexes.Add(new LwPolylineVertex(v20));
            Arc1.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
            fun.PolyFill(dxf, Arc1, 0.3, contour);
            LwPolyline Arc2 = new LwPolyline();
            Arc2.Vertexes.Add(new LwPolylineVertex(v25));
            Arc2.Vertexes.Add(new LwPolylineVertex(v26));
            Arc2.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
            fun.PolyFill(dxf, Arc2, 0.3, contour);
            LwPolyline Arc4 = new LwPolyline();
            Arc4.Vertexes.Add(new LwPolylineVertex(v18));
            Arc4.Vertexes.Add(new LwPolylineVertex(v19));
            Arc4.Vertexes[0].Bulge = 1 * scale / ((v18.Y - v19.Y) / 2.00);
            fun.PolyFill(dxf, Arc4, 0.3, contour);
            LwPolyline Arc5 = new LwPolyline();
            Arc5.Vertexes.Add(new LwPolylineVertex(v24));
            Arc5.Vertexes.Add(new LwPolylineVertex(v23));
            Arc5.Vertexes[0].Bulge = 1 * scale / ((v24.Y - v23.Y) / 2.00);
            fun.PolyFill(dxf, Arc5, 0.3, contour);
            Line line34 = new Line(v5, v35);
            line34.Lineweight = Lineweight.W25;
            line34.Layer = additionalline;
            dxf.AddEntity(line34);
            Line line35 = new Line(v14, v36);
            line35.Lineweight = Lineweight.W25;
            line35.Layer = additionalline;
            dxf.AddEntity(line35);
            /*Vector2[] Line36 = { v34, v31 };
            fun.drawBLine(dxf, Line36, 0.3, contour);
            Vector2[] Line37 = { v33, v30 };
            fun.drawBLine(dxf, Line37, 0.3, contour);*/
            Line Line36 = new Line(v34, v31);
            Line36.Layer = contour;
            dxf.AddEntity(Line36);
            Line Line37 = new Line(v33, v30);
            Line37.Layer = contour;
            dxf.AddEntity(Line37);
            Vector2[] Line38 = { v41, v42 };
            fun.drawPlinetype(dxf, Line38, 0.15, centre, Linetype.Center);
            Vector2[] Line39 = { v18, v20 };
            fun.drawBLine(dxf, Line39, 0.15, contour);
            Vector2[] Line40 = { v19, v21 };
            fun.drawBLine(dxf, Line40, 0.15, contour);
            Vector2[] Line41 = { v24, v26 };
            fun.drawBLine(dxf, Line41, 0.15, contour);
            Vector2[] Line42 = { v23, v25 };
            fun.drawBLine(dxf, Line42, 0.15, contour);
            Line Line43 = new Line(v1, v43);
            Line Line44 = new Line(v1, v44);
            List<Vector3> point1 = new List<Vector3>
            {
                fun.Tothree(v31),
                fun.Tothree(v32),
                fun.Tothree(v28),
                fun.Tothree(v29),
                fun.Tothree(v30),
            };
            Spline spline1 = new Spline(point1);
            spline1.Layer = contour;
            dxf.AddEntity(spline1);
            //fun.PolyFill(dxf, spline1, 0.3, contour);
            Vector2[] Line55 = { v80, v81 };
            fun.drawBLine(dxf, Line55, 0.3, contour);
            Vector2[] Line56 = { v82, v8 };
            fun.drawBLine(dxf, Line56, 0.3, contour);
            Vector2[] Line57 = { v83, v11 };
            fun.drawBLine(dxf, Line57, 0.3, contour);
            //柄方
            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(v47));
            poly1.Vertexes.Add(new LwPolylineVertex(v49));
            poly1.Vertexes.Add(new LwPolylineVertex(v50));
            poly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v52));
            poly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v53));
            poly1.Vertexes.Add(new LwPolylineVertex(v55));
            poly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v56));
            poly1.Vertexes.Add(new LwPolylineVertex(v46));
            poly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            poly1.IsClosed = true;
            fun.PolyFill(dxf, poly1, 0.3, contour);
            Line Line53 = new Line(v57, v58);
            Line Line54 = new Line(v59, v60);
            //主视图图层
            Line43.Layer = dimensioning;
            Line44.Layer = dimensioning;
            //柄方图层
            Line53.Layer = centre;
            Line54.Layer = centre;
            Line53.Linetype = Linetype.Center;
            Line54.Linetype = Linetype.Center;
            //主视图
            dxf.AddEntity(Line43);
            dxf.AddEntity(Line44);
            //柄方
            dxf.AddEntity(Line53);
            dxf.AddEntity(Line54);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 2.5;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v1, v43), new Line(v1, v44), offset * 3, dimensionStyle);
            angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v3, v16), -v3.X + v43.X - offset - 5, 270, dimensionStyle);
            dim2.UserText = "TD = " + Math.Round(td / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            double toh = Convert.ToDouble(data["thltctrh"]);
            double tol = Convert.ToDouble(data["thltctrl"]);
            if (toh == 0 && tol == 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v17, v15), -offset, 0, dimensionStyle);
                dim3.UserText = "THL = " + Math.Round(thl / scale, 2);
                dxf.AddEntity(dim3);
            }
            else
            {
                fun.dimrot(dxf, v17, v15, 0, -offset, 2.5, 2, 2.5, "THL = " + Math.Round(thl / scale, 2), toh + "", tol + "");
            }
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v17, v13), -offset*2, 0, dimensionStyle);
            dim4.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            double toh1 = Convert.ToDouble(data["oaltctrh"]);
            double tol1 = Convert.ToDouble(data["oaltctrl"]);
            string oaltctr = Convert.ToString(data["oaltctr"]);
            if (toh1 == 0 && tol1 == 0)
            {
                if (oaltctr.Equals("0"))
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 4, 0, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 4, 0, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2) + "  " + oaltctr;
                    dxf.AddEntity(dim5);
                }


            }
            else
            {
                fun.dimrot(dxf, v17, v10, 0, -offset * 2, 2.5, 2, 2.5, "OAL = " + Math.Round(oal / scale, 2), toh1 + "", tol1 + "");
            }

            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v23, v26), -offset - (v26.Y - v11.Y), 0, dimensionStyle);
            dim6.UserText = "DRVL = " + Math.Round(drvl / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            string tcdconws = Convert.ToString(data["tcdconws"]);
            if (tcdconws.Equals("0"))
            {
                LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim7);
            }
            else
            {
                LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2) + "  " + tcdconws;
                dxf.AddEntity(dim7);
            }


            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v46, v50), -offset, 135, dimensionStyle);
            dim8.UserText = "DRVSC = " + Math.Round(drvsc / scale, 2);
            dxf.AddEntity(dim8);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
            hatchpoly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
            hatchpoly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
            hatchpoly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
            hatchpoly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 89, 5, hline1, harc1, hatching);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v1.X - 210 + (v45.X + v8.Y - v1.X) / 2.00, v1.Y + 148.5), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void SpiralFluteTap(Dictionary<string, Object> data)    //螺旋槽带尖丝锥(粗柄)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           // 非空判断
            if (data["lu"].Equals("")) data["lu"] = 0;
            if (data["dn"].Equals("")) data["dn"] = 0;

            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 105)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 210)
            {
                scale = 1.0;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }

            double pi = Math.PI;
            double td = Convert.ToDouble(data["td"]) * scale;
            double dmm = Convert.ToDouble(data["dconms"]) * scale;
            double tp = Convert.ToDouble(data["tp"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            if (dn == 0)
            {
                dn = td - 1.1325 * tp - 0.15;
            }
            double mc = Convert.ToDouble(data["mc"]);
            double qxzj;
            if (mc == 0)
            {
                qxzj = 4.5 * pi / 180;
            }
            if (mc == 1)
            {
                qxzj = 8.5 * pi / 180;
            }
            if (mc == 2)
            {
                qxzj = 17 * pi / 180;
            }
            else
            {
                qxzj = 6 * pi / 180;
            }

            double tcl;
            if (mc == 0)
            {
                tcl = 8 * tp;
            }
            else if (mc == 1)
            {
                tcl = 4 * tp;
            }
            else if (mc == 2)
            {
                tcl = 2 * tp;
            }
            else
            {
                tcl = 6 * tp;
            }

            if (tcl == 0)
            {
                tcl = tp * 2.3;
            }
            double tcpd = td - tcl * Math.Tan(qxzj);
            double thl = Convert.ToDouble(data["thl"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;
            if (lu == 0)
            {
                lu = thl * 39 / 22;
            }
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
            double drvl = Convert.ToDouble(data["drvl"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double FHA = Convert.ToDouble(data["fha"]);
            double ta = Convert.ToDouble(data["ta"]) * pi / 180;
            double ds = dmm - 0.08 * scale;//柄方外圆
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v2 = new Vector2(-oal / 2.00, tcpd / 2.00);
            Vector2 v1 = new Vector2(v2.X - v2.Y / Math.Tan(sig / 2.00), 0);
            Vector2 v3 = new Vector2(v2.X + tcl, td / 2.00);
            Vector2 v4 = new Vector2(v2.X + thl, v3.Y);
            Vector2 v5 = new Vector2((td - dn) / 2.00 + v4.X, dn / 2.00);
            Vector2 v6 = new Vector2(v2.X + lu, v5.Y);
            Vector2 v7 = new Vector2((dmm - dn) / 2.00 / Math.Tan(ta) + v6.X, dmm / 2.00);
            Vector2 v8 = new Vector2(v2.X + oal - 0.15 * dmm, ds / 2);
            Vector2 v9 = new Vector2(v2.X + oal, 0.35 * dmm);
            Vector2 v10 = new Vector2(v9.X, -v9.Y);
            Vector2 v11 = new Vector2(v8.X, -v8.Y);
            Vector2 v12 = new Vector2(v7.X, -v7.Y);
            Vector2 v13 = new Vector2(v6.X, -v6.Y);
            Vector2 v14 = new Vector2(v5.X, -v5.Y);
            Vector2 v15 = new Vector2(v4.X, -v4.Y);
            Vector2 v16 = new Vector2(v3.X, -v3.Y);
            Vector2 v17 = new Vector2(v2.X, -v2.Y);
            Vector2 v19 = new Vector2(v8.X - drvl, dmm * (1.7 / 22.42));
            Vector2 v18 = new Vector2(v19.X, v8.Y);
            Vector2 p19_1 = fun.Polar(v18, pi, oal * (1.29 / 166.56));
            Vector2 p19_2 = fun.Polar(p19_1, -90.001 * pi / 180, oal);
            Vector2 v20 = new Vector2(v8.X, v19.Y);
            Vector2 v21 = new Vector2(v20.X, v18.Y);
            Vector2 p21_1 = fun.Polar(v21, 0, oal * (1.29 / 166.56));
            Vector2 p21_2 = fun.Polar(p21_1, -90.001 * pi / 180, oal);
            Vector2 v22 = new Vector2(v21.X - (v18.Y - v19.Y) / 2.00 * Math.Tan(60 * pi / 180), (v18.Y + v19.Y) / 2.00);
            Vector2 v23 = new Vector2(v18.X, -v18.Y);
            Vector2 v24 = new Vector2(v19.X, -v19.Y);
            Vector2 v25 = new Vector2(v20.X, -v20.Y);
            Vector2 v26 = new Vector2(v21.X, -v21.Y);
            Vector2 v27 = new Vector2(v22.X, -v22.Y);
            Vector2 v41 = new Vector2(v1.X - 2, v1.Y);
            Vector2 v42 = new Vector2(v9.X + 2, v1.Y);
            Vector2 v43 = new Vector2(2 * v1.X - v17.X, v2.Y);
            Vector2 v44 = new Vector2(2 * v1.X - v2.X, v17.Y);
            Vector2 v80 = new Vector2(v8.X - drvl - 1 * scale, v7.Y);
            Vector2 v81 = new Vector2(v80.X, -v80.Y);
            Vector2 v82 = new Vector2(v80.X, ds / 2.00);
            Vector2 v83 = new Vector2(v82.X, -v82.Y);
            //柄方
            Vector2 v45 = new Vector2(105 + oal / 4.00, v8.Y - (v20.Y - v25.Y) * Math.Cos(45 * pi / 180));
            Vector2 v46 = new Vector2(v45.X - (v20.Y - v25.Y) / 2.00, v45.Y + (v20.Y - v25.Y) / 2.00);
            Vector2 v47 = new Vector2(v45.X * 2 - v46.X, v46.Y);
            Vector2 v48 = new Vector2(v45.X + v45.Y, v1.Y);
            Vector2 v49 = new Vector2(v45.X + v46.Y, v48.Y + v47.X - v45.X);
            Vector2 v50 = new Vector2(v49.X, -v49.Y);
            Vector2 v51 = new Vector2(v45.X, -v45.Y);
            Vector2 v52 = new Vector2(v47.X, -v47.Y);
            Vector2 v53 = new Vector2(v46.X, -v46.Y);
            Vector2 v54 = new Vector2(v45.X * 2 - v48.X, v48.Y);
            Vector2 v55 = new Vector2(v45.X * 2 - v50.X, v50.Y);
            Vector2 v56 = new Vector2(v45.X * 2 - v49.X, v49.Y);
            Vector2 v57 = new Vector2(v45.X - ds / 2.00 - 2, 0);
            Vector2 v58 = new Vector2(v45.X + ds / 2.00 + 2, 0);
            Vector2 v59 = new Vector2(v45.X, ds / 2.00 + 2);
            Vector2 v60 = new Vector2(v59.X, -v59.Y);
            /*
            fun.seevector2(dxf, 1.2, 1, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23
                , v24, v25, v26, v27);
            fun.seevector2(dxf, 1.2, 41, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59,
                v60);
            fun.seevector2(dxf, 1.2, 80, v80, v81, v82, v83);
            */
            string tctr = Convert.ToString(data["tctr"]);
            if (!tctr.Equals("0"))
            {
                Vector2 a1 = fun.Polar(v3, fun.CalAngle(v3, v4), fun.CalDistance(v3, v4) / 2);
                Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                Line line101 = new Line(a1, a2);
                dxf.AddEntity(line101);
                fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

            }
            //线段
            //主视图

            double dx = v2.X;
            if (tcpd < dn)
            {
                dx = (v5.Y - oal * (td - tcpd) / 4 / tcl - tcpd / 2) * 2 * tcl / (td - tcpd);
            }
            Vector2 v35 = new Vector2(dx, v5.Y);
            Vector2 v36 = new Vector2(dx, v14.Y);
            Line line34 = new Line(v5, v35);
            line34.Lineweight = Lineweight.W25;
            line34.Layer = additionalline;
            dxf.AddEntity(line34);
            Line line35 = new Line(v14, v36);
            line35.Lineweight = Lineweight.W25;
            line35.Layer = additionalline;
            dxf.AddEntity(line35);

            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v80 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v81, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v1 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v2, v17 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line23 = { v6, v13 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v7, v12 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v8, v21 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { v20, v25 };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            Vector2[] Line27 = { v26, v11 };
            fun.drawBLine(dxf, Line27, 0.3, contour);
            Vector2[] Line28 = { v21, v18 };
            fun.drawBLine(dxf, Line28, 0.3, contour);
            Vector2[] Line29 = { v18, v19 };
            fun.drawBLine(dxf, Line29, 0.3, contour);
            Vector2[] Line30 = { v19, v20 };
            fun.drawBLine(dxf, Line30, 0.3, contour);
            Vector2[] Line31 = { v25, v24 };
            fun.drawBLine(dxf, Line31, 0.3, contour);
            Vector2[] Line32 = { v24, v23 };
            fun.drawBLine(dxf, Line32, 0.3, contour);
            Vector2[] Line33 = { v23, v26 };
            fun.drawBLine(dxf, Line33, 0.3, contour);
            //Arc Arc1 = new Arc(v22, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
            //Arc Arc2 = new Arc(v27, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
            /* LwPolyline Arc1 = new LwPolyline();
             Arc1.Vertexes.Add(new LwPolylineVertex(v21));
             Arc1.Vertexes.Add(new LwPolylineVertex(v20));
             Arc1.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
             fun.PolyFill(dxf, Arc1, 0.3, contour);*/
            Arc arc1 = fun.DrawArc5(v20, new Line(p21_1, p21_2), v21);
            Arc arc2 = fun.DrawArc5(v26, new Line(p21_1, p21_2), v25);
            Arc arc3 = fun.DrawArc5(v18, new Line(p19_1, p19_2), v19);
            Arc arc4 = fun.DrawArc5(v24, new Line(p19_1, p19_2), v23);
            fun.drawBArc(dxf, arc1, 0.3, contour);
            fun.drawBArc(dxf, arc2, 0.3, contour);
            fun.drawBArc(dxf, arc3, 0.3, contour);
            fun.drawBArc(dxf, arc4, 0.3, contour);
            /* LwPolyline Arc2 = new LwPolyline();
             Arc2.Vertexes.Add(new LwPolylineVertex(v25));
             Arc2.Vertexes.Add(new LwPolylineVertex(v26));
             Arc2.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
             fun.PolyFill(dxf, Arc2, 0.3, contour);*/
            /*LwPolyline Arc4 = new LwPolyline();
            Arc4.Vertexes.Add(new LwPolylineVertex(v18));
            Arc4.Vertexes.Add(new LwPolylineVertex(v19));
            Arc4.Vertexes[0].Bulge = 1 * scale / ((v18.Y - v19.Y) / 2.00);
            fun.PolyFill(dxf, Arc4, 0.3, contour);
            LwPolyline Arc5 = new LwPolyline();
            Arc5.Vertexes.Add(new LwPolylineVertex(v24));
            Arc5.Vertexes.Add(new LwPolylineVertex(v23));
            Arc5.Vertexes[0].Bulge = 1 * scale / ((v24.Y - v23.Y) / 2.00);
            fun.PolyFill(dxf, Arc5, 0.3, contour);*/
            Vector2[] Line38 = { v41, v42 };
            fun.drawPlinetype(dxf, Line38, 0.15, centre, Linetype.Center);
            Vector2[] Line39 = { v18, v20 };
            fun.drawBLine(dxf, Line39, 0.15, contour);
            Vector2[] Line40 = { v19, v21 };
            fun.drawBLine(dxf, Line40, 0.15, contour);
            Vector2[] Line41 = { v24, v26 };
            fun.drawBLine(dxf, Line41, 0.15, contour);
            Vector2[] Line42 = { v23, v25 };
            fun.drawBLine(dxf, Line42, 0.15, contour);
            Line Line43 = new Line(v1, v43);
            Line Line44 = new Line(v1, v44);
            Vector2[] Line55 = { v80, v81 };
            fun.drawBLine(dxf, Line55, 0.3, contour);
            Vector2[] Line56 = { v82, v8 };
            fun.drawBLine(dxf, Line56, 0.3, contour);
            Vector2[] Line57 = { v83, v11 };
            fun.drawBLine(dxf, Line57, 0.3, contour);
            //柄方
            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(v47));
            poly1.Vertexes.Add(new LwPolylineVertex(v49));
            poly1.Vertexes.Add(new LwPolylineVertex(v50));
            poly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v52));
            poly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v53));
            poly1.Vertexes.Add(new LwPolylineVertex(v55));
            poly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v56));
            poly1.Vertexes.Add(new LwPolylineVertex(v46));
            poly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            poly1.IsClosed = true;
            fun.PolyFill(dxf, poly1, 0.3, contour);
            Line Line53 = new Line(v57, v58);
            Line Line54 = new Line(v59, v60);
            //主视图图层
            Line43.Layer = dimensioning;
            Line44.Layer = dimensioning;
            //柄方图层
            Line53.Layer = centre;
            Line54.Layer = centre;
            Line53.Linetype = Linetype.Center;
            Line54.Linetype = Linetype.Center;
            //主视图
            dxf.AddEntity(Line43);
            dxf.AddEntity(Line44);
            //柄方
            dxf.AddEntity(Line53);
            dxf.AddEntity(Line54);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 1.2 * (oal / 151.0);
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.25 * (oal / 151.0);
            double offset = 10 * (oal / 151.0);
            //线段尺寸标注
            //尺寸1
            /*
            Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v1, v43), new Line(v1, v44), offset, dimensionStyle);
            angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim1);*/

            //fun.jdbz2(dxf, new Line(v1, v43), new Line(v1, v44), offset * 1.5, 1.25 * (oal / 151.0), 1.2 * (oal / 151.0), 0.4, "SIG = " + Math.Round(sig / (pi / 180), 2) + "°", "", "");
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v3, v16), (-v3.X + v43.X - offset - 5) * 1.3, 270, dimensionStyle);
            dim2.UserText = "TD = " + Math.Round(td / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            double toh = Convert.ToDouble(data["thltctrh"]);
            double tol = Convert.ToDouble(data["thltctrl"]);
            if (toh == 0 && tol == 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v17, v15), -offset, 0, dimensionStyle);
                dim3.UserText = "THL = " + Math.Round(thl / scale, 2);
                dxf.AddEntity(dim3);
            }
            else
            {
                fun.dimrot(dxf, v17, v15, 0, -offset, 2.5, 2, 2.5, "THL = " + Math.Round(thl / scale, 2), toh + "", tol + "");
            }
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v17, v13), -offset - 5, 0, dimensionStyle);
            dim4.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            double toh1 = Convert.ToDouble(data["oaltctrh"]);
            double tol1 = Convert.ToDouble(data["oaltctrl"]);
            string oaltctr = Convert.ToString(data["oaltctr"]);
            if (toh1 == 0 && tol1 == 0)
            {
                if (oaltctr.Equals("0"))
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 2.5, 0, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 2.5, 0, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2) + "  " + oaltctr;
                    dxf.AddEntity(dim5);
                }


            }
            else
            {
                fun.dimrot(dxf, v17, v10, 0, -offset * 2, 2.5, 2, 2.5, "OAL = " + Math.Round(oal / scale, 2), toh1 + "", tol1 + "");
            }

            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v23, v26), -offset - (v26.Y - v11.Y), 0, dimensionStyle);
            dim6.UserText = "DRVL = " + Math.Round(drvl / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            string tcdconws = Convert.ToString(data["tcdconws"]);
            if (tcdconws.Equals("0"))
            {
                LinearDimension dim7 = new LinearDimension(new Line(v80, v81), (v9.X - v80.X + offset) * 1.3, 270, dimensionStyle);
                dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim7);
            }
            else
            {
                LinearDimension dim7 = new LinearDimension(new Line(v80, v81), (v9.X - v80.X + offset) * 1.3, 270, dimensionStyle);
                dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2) + "  " + tcdconws;
                dxf.AddEntity(dim7);
            }


            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v46, v50), -offset * 2, 135, dimensionStyle);
            dim8.UserText = "DRVSC = " + Math.Round(drvsc / scale, 2);
            dxf.AddEntity(dim8);
            //填充柄方
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
            hatchpoly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
            hatchpoly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
            hatchpoly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
            hatchpoly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 89, 5 * (oal / 151.0), hline1, harc1, hatching);
            /* //填充螺旋槽
             LwPolyline hatchpoly2 = new LwPolyline();
             hatchpoly2.Vertexes.Add(new LwPolylineVertex(v2));
             hatchpoly2.Vertexes.Add(new LwPolylineVertex(v3));
             hatchpoly2.Vertexes.Add(new LwPolylineVertex(v4));
             hatchpoly2.Vertexes.Add(new LwPolylineVertex(v5));
             hatchpoly2.Vertexes.Add(new LwPolylineVertex(v6));
             hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
             hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
             hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
             hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
             hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
             hatchpoly2.IsClosed = true;
             String[] htype2 = new String[100];
             Line[] hline2 = new Line[100];
             int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
             for (int i = 0; i < hnumst2; i++)
             {
                 htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                 if (htype2[i] == "Line")
                 {
                     hline2[i] = (Line)hatchpoly2.Explode()[i];
                 }
             }
             var x = lu / 5.00 * Math.Tan(FHA * pi / 180);
             if (x < tcpd / 2.00)
             {
                 fun.hatchsuboflinew(dxf, htype2, hnumst2, -FHA, lu / 2.00 * 8 * Math.Sin(FHA * pi / 180), hline2, contour, 0.3);
             }
             else
             {
                 fun.hatchsuboflinew(dxf, htype2, hnumst2, -FHA, lu / 5.00 * 8 * Math.Sin(FHA * pi / 180), hline2, contour, 0.3);
             }*/


            double lxxx = Convert.ToDouble(data["lxxx"]);
            if (lxxx == 0)
            {
                Vector2 v01 = fun.Polar(v17, 90 * pi / 180, tcpd / 4);
                Vector2 v02p = fun.Polar(v01, -FHA * pi / 180, 10);
                Vector2 v02 = fun.Inters(v01, v02p, v15, v16);
                Vector2 v03 = fun.Polar(v17, 90 * pi / 180, tcpd / 6 * 4);
                Vector2 v04p = fun.Polar(v03, -FHA * pi / 180, 10);
                Vector2 v04;
                if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v03.Y - v15.Y)) * 180 / pi)
                {
                    v04 = fun.Inters(v03, v04p, v4, v15);
                }
                else
                {
                    v04 = fun.Inters(v03, v04p, v15, v16);
                }

                Vector2 v05 = new Vector2(v2.X, v2.Y);
                Vector2 v06p = fun.Polar(v05, -FHA * pi / 180, 10);
                Vector2 v06;
                if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v05.Y - v15.Y)) * 180 / pi)
                {
                    v06 = fun.Inters(v05, v06p, v4, v15);
                }
                else
                {
                    v06 = fun.Inters(v05, v06p, v15, v16);
                }
                Vector2 v07p = fun.Polar(v05, 90 * pi / 180, (v03.Y - v01.Y));
                Vector2 v08p = fun.Polar(v07p, -FHA * pi / 180, 10);
                Vector2 v07 = fun.Inters(v07p, v08p, v3, v4);
                Vector2 v08;
                if (FHA <= 90 - Math.Atan((v15.X - v07.X) / (v07.Y - v15.Y)) * 180 / pi)
                {
                    v08 = fun.Inters(v07, v08p, v4, v15);
                }
                else
                {
                    v08 = fun.Inters(v07, v08p, v15, v16);
                }
                Vector2[] Line01 = { v4, v15 };
                fun.drawBLine(dxf, Line01, 0.3, contour);
                Line line01 = new Line(v01, v02);
                line01.Lineweight = Lineweight.W25;
                line01.Layer = additionalline;
                dxf.AddEntity(line01);
                Line line02 = new Line(v03, v04);
                line02.Lineweight = Lineweight.W25;
                line02.Layer = additionalline;
                dxf.AddEntity(line02);
                Line line03 = new Line(v05, v06);
                line03.Lineweight = Lineweight.W25;
                line03.Layer = additionalline;
                dxf.AddEntity(line03);
                Line line04 = new Line(v07, v08);
                line04.Lineweight = Lineweight.W25;
                line04.Layer = additionalline;
                dxf.AddEntity(line04);


                LwPolyline hatchpoly01 = new LwPolyline();
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v01));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v17));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v16));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v02));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v01));
                hatchpoly01.IsClosed = true;
                String[] htype01 = new String[100];
                Line[] hline01 = new Line[100];
                Arc[] harc01 = new Arc[100];
                int hnumst01 = hatchpoly01.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst01; i++)
                {
                    htype01[i] = hatchpoly01.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype01[i] == "Line")
                    {
                        hline01[i] = (Line)hatchpoly01.Explode()[i];
                    }
                    if (htype01[i] == "Arc")
                    {
                        harc01[i] = (Arc)hatchpoly01.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype01, hnumst01, 89, 5 * (oal / 151.0), hline01, harc01, hatching);





                LwPolyline hatchpoly02 = new LwPolyline();
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v03));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v04));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v06));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v05));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v03));
                hatchpoly02.IsClosed = true;
                String[] htype02 = new String[102];
                Line[] hline02 = new Line[102];
                Arc[] harc02 = new Arc[102];
                int hnumst02 = hatchpoly02.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst02; i++)
                {
                    htype02[i] = hatchpoly02.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype02[i] == "Line")
                    {
                        hline02[i] = (Line)hatchpoly02.Explode()[i];
                    }
                    if (htype02[i] == "Arc")
                    {
                        harc02[i] = (Arc)hatchpoly02.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype02, hnumst02, 89, 5 * (oal / 151.0), hline02, harc02, hatching);


                LwPolyline hatchpoly03 = new LwPolyline();
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v07));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v08));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v07));
                hatchpoly03.IsClosed = true;
                String[] htype03 = new String[103];
                Line[] hline03 = new Line[103];
                Arc[] harc03 = new Arc[103];
                int hnumst03 = hatchpoly03.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst03; i++)
                {
                    htype03[i] = hatchpoly03.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype03[i] == "Line")
                    {
                        hline03[i] = (Line)hatchpoly03.Explode()[i];
                    }
                    if (htype03[i] == "Arc")
                    {
                        harc03[i] = (Arc)hatchpoly03.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype03, hnumst03, 89, 5 * (oal / 151.0), hline03, harc03, hatching);


                dimensionStyle.TextHeight = 1;

                Angular2LineDimension angdim2 = new Angular2LineDimension(new Line(v05, v06), new Line(v41, v42), offset * 5, dimensionStyle);
                angdim2.UserText = "FHA = " + FHA + "°";
                dxf.AddEntity(angdim2);


                //fun.jdbz2(dxf, new Line(v41, v42), new Line(v05, v06), offset * 5, 2.5, 0.8, 0.4, "FHA = " + FHA + "°", "", "");

            }
            else
            {
                Vector2 v01 = fun.Polar(v17, 90 * pi / 180, tcpd / 4);
                Vector2 v02p = fun.Polar(v01, -FHA * pi / 180, 10);
                Vector2 v02 = fun.Inters(v01, v02p, v15, v16);
                Vector2 v03 = fun.Polar(v17, 90 * pi / 180, tcpd / 6 * 4);
                Vector2 v04p = fun.Polar(v03, -FHA * pi / 180, 10);
                Vector2 v04;
                if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v03.Y - v15.Y)) * 180 / pi)
                {
                    v04 = fun.Inters(v03, v04p, v4, v15);
                }
                else
                {
                    v04 = fun.Inters(v03, v04p, v15, v16);
                }

                Vector2 v05 = new Vector2(v2.X, v2.Y);
                Vector2 v06p = fun.Polar(v05, -FHA * pi / 180, 10);
                Vector2 v06;
                if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v05.Y - v15.Y)) * 180 / pi)
                {
                    v06 = fun.Inters(v05, v06p, v4, v15);
                }
                else
                {
                    v06 = fun.Inters(v05, v06p, v15, v16);
                }
                Vector2 v07p = fun.Polar(v05, 90 * pi / 180, (v03.Y - v01.Y));
                Vector2 v08p = fun.Polar(v07p, -FHA * pi / 180, 10);
                Vector2 v07 = fun.Inters(v07p, v08p, v3, v4);
                Vector2 v08;
                if (FHA <= 90 - Math.Atan((v15.X - v07.X) / (v07.Y - v15.Y)) * 180 / pi)
                {
                    v08 = fun.Inters(v07, v08p, v4, v15);
                }
                else
                {
                    v08 = fun.Inters(v07, v08p, v15, v16);
                }

                Vector2 a1 = new Vector2(v01.X, -v01.Y);
                Vector2 a2 = new Vector2(v02.X, -v02.Y);
                Vector2 a3 = new Vector2(v03.X, -v03.Y);
                Vector2 a4 = new Vector2(v04.X, -v04.Y);
                Vector2 a5 = new Vector2(v05.X, -v05.Y);
                Vector2 a6 = new Vector2(v06.X, -v06.Y);
                Vector2 a7 = new Vector2(v07.X, -v07.Y);
                Vector2 a8 = new Vector2(v08.X, -v08.Y);



                Vector2[] Line01 = { v4, v15 };
                fun.drawBLine(dxf, Line01, 0.3, contour);
                Line line01 = new Line(a1, a2);
                line01.Lineweight = Lineweight.W25;
                line01.Layer = additionalline;
                dxf.AddEntity(line01);
                Line line02 = new Line(a3, a4);
                line02.Lineweight = Lineweight.W25;
                line02.Layer = additionalline;
                dxf.AddEntity(line02);
                Line line03 = new Line(a5, a6);
                line03.Lineweight = Lineweight.W25;
                line03.Layer = additionalline;
                dxf.AddEntity(line03);
                Line line04 = new Line(a7, a8);
                line04.Lineweight = Lineweight.W25;
                line04.Layer = additionalline;
                dxf.AddEntity(line04);



                LwPolyline hatchpoly01 = new LwPolyline();
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(a1));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(a2));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(a1));
                hatchpoly01.IsClosed = true;
                String[] htype01 = new String[100];
                Line[] hline01 = new Line[100];
                Arc[] harc01 = new Arc[100];
                int hnumst01 = hatchpoly01.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst01; i++)
                {
                    htype01[i] = hatchpoly01.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype01[i] == "Line")
                    {
                        hline01[i] = (Line)hatchpoly01.Explode()[i];
                    }
                    if (htype01[i] == "Arc")
                    {
                        harc01[i] = (Arc)hatchpoly01.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype01, hnumst01, 89, 5 * (oal / 151.0), hline01, harc01, hatching);





                LwPolyline hatchpoly02 = new LwPolyline();
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(a3));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(a4));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(a6));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(a5));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(a3));
                hatchpoly02.IsClosed = true;
                String[] htype02 = new String[102];
                Line[] hline02 = new Line[102];
                Arc[] harc02 = new Arc[102];
                int hnumst02 = hatchpoly02.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst02; i++)
                {
                    htype02[i] = hatchpoly02.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype02[i] == "Line")
                    {
                        hline02[i] = (Line)hatchpoly02.Explode()[i];
                    }
                    if (htype02[i] == "Arc")
                    {
                        harc02[i] = (Arc)hatchpoly02.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype02, hnumst02, 89, 5 * (oal / 151.0), hline02, harc02, hatching);


                LwPolyline hatchpoly03 = new LwPolyline();
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(a7));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(a8));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(a7));
                hatchpoly03.IsClosed = true;
                String[] htype03 = new String[103];
                Line[] hline03 = new Line[103];
                Arc[] harc03 = new Arc[103];
                int hnumst03 = hatchpoly03.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst03; i++)
                {
                    htype03[i] = hatchpoly03.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype03[i] == "Line")
                    {
                        hline03[i] = (Line)hatchpoly03.Explode()[i];
                    }
                    if (htype03[i] == "Arc")
                    {
                        harc03[i] = (Arc)hatchpoly03.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype03, hnumst03, 89, 5 * (oal / 151.0), hline03, harc03, hatching);


                dimensionStyle.TextHeight = 1;

                Angular2LineDimension angdim2 = new Angular2LineDimension(new Line(a5, a6), new Line(v41, v42), offset * 5, dimensionStyle);
                angdim2.UserText = "FHA = " + FHA + "°";
                dxf.AddEntity(angdim2);

                //fun.jdbz2(dxf, new Line(v41, v42), new Line(a5, a6), offset * 5, 2.5, 0.8, 0.4, "FHA = " + FHA + "°", "", "");
            }


            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v1.X - 210 + (v45.X + v8.Y - v1.X) / 2.00, v1.Y + 148.5), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void SpiralPointedTap(Dictionary<string, Object> data)    //带尖螺尖丝锥(粗柄)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 105)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 210)
            {
                scale = 1.0;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double td = Convert.ToDouble(data["td"]) * scale;
            double dmm = Convert.ToDouble(data["dconms"]) * scale;
            double tp = Convert.ToDouble(data["tp"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            if (dn == 0)
            {
                dn = td - 1.1325 * tp - 0.15;
            }

            double mc = Convert.ToDouble(data["mc"]);
            double qxzj;
            if (mc == 0)
            {
                qxzj = 4.5 * pi / 180;
            }
            if (mc == 1)
            {
                qxzj = 8.5 * pi / 180;
            }
            if (mc == 2)
            {
                qxzj = 17 * pi / 180;
            }
            else
            {
                qxzj = 6 * pi / 180;
            }

            double tcl;
            if (mc == 0)
            {
                tcl = 8 * tp;
            }
            else if (mc == 1)
            {
                tcl = 4 * tp;
            }
            else if (mc == 2)
            {
                tcl = 2 * tp;
            }
            else
            {
                tcl = 6 * tp;
            }
            double tcpd = td - tcl * Math.Tan(qxzj);
            double thl = Convert.ToDouble(data["thl"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;
            if (lu == 0)
            {
                lu = thl * 39 / 22;
            }
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
            double drvl = Convert.ToDouble(data["drvl"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double ta = Convert.ToDouble(data["ta"]) * pi / 180;
            double ds = dmm - 0.08 * scale;//柄方外圆
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v2 = new Vector2(-oal / 2.00, tcpd / 2.00);
            Vector2 v1 = new Vector2(v2.X - v2.Y / Math.Tan(sig / 2.00), 0);
            Vector2 v3 = new Vector2(v2.X + tcl, td / 2.00);
            Vector2 v4 = new Vector2(v2.X + thl, v3.Y);
            Vector2 v5 = new Vector2((td - dn) / 2.00 + v4.X, dn / 2.00);
            Vector2 v6 = new Vector2(v2.X + lu, v5.Y);
            Vector2 v7 = new Vector2((dmm - dn) / 2.00 / Math.Tan(ta) + v6.X, dmm / 2.00);
            Vector2 v8 = new Vector2(v2.X + oal - 0.15 * dmm, ds / 2);
            Vector2 v9 = new Vector2(v2.X + oal, 0.35 * dmm);
            Vector2 v10 = new Vector2(v9.X, -v9.Y);
            Vector2 v11 = new Vector2(v8.X, -v8.Y);
            Vector2 v12 = new Vector2(v7.X, -v7.Y);
            Vector2 v13 = new Vector2(v6.X, -v6.Y);
            Vector2 v14 = new Vector2(v5.X, -v5.Y);
            Vector2 v15 = new Vector2(v4.X, -v4.Y);
            Vector2 v16 = new Vector2(v3.X, -v3.Y);
            Vector2 v17 = new Vector2(v2.X, -v2.Y);
            Vector2 v19 = new Vector2(v8.X - drvl, ds / 2.00 * (Math.Sin(45 * pi / 180) * drvsc / ds - Math.Cos(45 * pi / 180) * Math.Sqrt(1 - (drvsc * drvsc) / (ds * ds))));
            Vector2 v18 = new Vector2(v19.X, drvsc * Math.Sin(45 * pi / 180) - v19.Y);
            Vector2 v20 = new Vector2(v8.X, v19.Y);
            Vector2 v21 = new Vector2(v20.X, v18.Y);
            Vector2 v22 = new Vector2(v21.X - (v18.Y - v19.Y) / 2.00 * Math.Tan(60 * pi / 180), (v18.Y + v19.Y) / 2.00);
            Vector2 v23 = new Vector2(v18.X, -v18.Y);
            Vector2 v24 = new Vector2(v19.X, -v19.Y);
            Vector2 v25 = new Vector2(v20.X, -v20.Y);
            Vector2 v26 = new Vector2(v21.X, -v21.Y);
            Vector2 v27 = new Vector2(v22.X, -v22.Y);
            Vector2 v41 = new Vector2(v1.X - 2, v1.Y);
            Vector2 v42 = new Vector2(v9.X + 2, v1.Y);
            Vector2 v43 = new Vector2(2 * v1.X - v17.X, v2.Y);
            Vector2 v44 = new Vector2(2 * v1.X - v2.X, v17.Y);
            //Vector2 v61 = new Vector2(Math.Sqrt(tp * tp * 49 - (v2.Y-v33.Y)* (v2.Y - v33.Y))+v2.X, wcf * 5 / 4.00);
            //Vector2 v63 = new Vector2(v61.X, v33.Y*2-v61.Y);
            //Vector2 v64 = new Vector2(v61.X - (v61.Y - v33.Y) / ((v61.X - v3.X) / (v3.Y - v61.Y)), v33.Y);
            //Vector2 v62 = new Vector2(v64.X + Math.Sqrt((v61.X - v64.X) * (v61.X - v64.X) + (v61.Y - v33.Y) * (v61.Y - v33.Y)), wcf / 2.00);
            Vector2 v80 = new Vector2(v8.X - drvl - 1 * scale, v7.Y);
            Vector2 v81 = new Vector2(v80.X, -v80.Y);
            Vector2 v82 = new Vector2(v80.X, ds / 2.00);
            Vector2 v83 = new Vector2(v82.X, -v82.Y);
            //螺尖槽
            Vector2 v87 = new Vector2(v2.X + tcpd * 5 / 36, v2.Y);
            Vector2 v88 = new Vector2(v2.X + tcl + thl / 5, v87.Y - 5 * tcpd / 18);
            Vector2 v86 = new Vector2(v87.X, v87.Y - 5 * tcpd / 9);
            Vector2 v89 = new Vector2(v87.X, v87.Y + (v87.X - v2.X) * (td - tcpd) / 2 / tcl);
            Vector2 v84 = new Vector2(v87.X, -v89.Y);
            Vector2 v85 = new Vector2(v86.X + (-v88.Y - v84.Y) * (td - tcpd) / 2 / tcl, -v88.Y);
            Vector2 v90 = new Vector2((v87.X - v88.X) * v88.Y * v88.Y / (v87.Y - v88.Y) / (v87.Y - v88.Y) + v88.X, 0);
            Vector2 v91 = new Vector2(v90.X, v88.Y * 2 - v90.Y);
            Vector2 v93 = new Vector2(v88.X, v15.Y);
            double cl = Math.Sqrt((v85.Y - v84.Y) * (v85.Y - v84.Y) + (v85.X - v84.X) * (v85.X - v84.X)) / 2;
            double sr = Math.Sqrt(cl * cl + (cl * (td - tcpd) / 2 / tcl) * (cl * (td - tcpd) / 2 / tcl));
            double h = sr - (td - tcpd) * cl / 2 / tcl;
            Vector2 v94 = new Vector2(v85.X, v85.Y - sr);
            Vector2 v92 = new Vector2(v87.X, Math.Sqrt(sr * sr - (v85.X - v86.X) * (v85.X - v86.X)) + v94.Y);
            //排屑槽
            Vector2 v95 = new Vector2(v2.X + lu - 3, v88.Y);
            double cr = (v5.Y - v88.Y) * 2;
            Vector2 v96 = new Vector2(v95.X - cr * Math.Sin(60 * pi / 180), v5.Y);
            Vector2 v97 = new Vector2(v95.X, -v95.Y);
            Vector2 v98 = new Vector2(v96.X, -v96.Y);
            //柄方
            Vector2 v45 = new Vector2(105 + oal / 4.00, v8.Y - (v20.Y - v25.Y) * Math.Cos(45 * pi / 180));
            Vector2 v46 = new Vector2(v45.X - (v20.Y - v25.Y) / 2.00, v45.Y + (v20.Y - v25.Y) / 2.00);
            Vector2 v47 = new Vector2(v45.X * 2 - v46.X, v46.Y);
            Vector2 v48 = new Vector2(v45.X + v45.Y, v1.Y);
            Vector2 v49 = new Vector2(v45.X + v46.Y, v48.Y + v47.X - v45.X);
            Vector2 v50 = new Vector2(v49.X, -v49.Y);
            Vector2 v51 = new Vector2(v45.X, -v45.Y);
            Vector2 v52 = new Vector2(v47.X, -v47.Y);
            Vector2 v53 = new Vector2(v46.X, -v46.Y);
            Vector2 v54 = new Vector2(v45.X * 2 - v48.X, v48.Y);
            Vector2 v55 = new Vector2(v45.X * 2 - v50.X, v50.Y);
            Vector2 v56 = new Vector2(v45.X * 2 - v49.X, v49.Y);
            Vector2 v57 = new Vector2(v45.X - ds / 2.00 - 2, 0);
            Vector2 v58 = new Vector2(v45.X + ds / 2.00 + 2, 0);
            Vector2 v59 = new Vector2(v45.X, ds / 2.00 + 2);
            Vector2 v60 = new Vector2(v59.X, -v59.Y);
            string tctr = Convert.ToString(data["tctr"]);
            if (!tctr.Equals("0"))
            {
                Vector2 a1 = fun.Polar(v3, fun.CalAngle(v3, v4), fun.CalDistance(v3, v4) / 2);
                Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                Line line101 = new Line(a1, a2);
                dxf.AddEntity(line101);
                fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

            }
            //线段
            //主视图

            double dx = v2.X;
            if (tcpd < dn)
            {
                dx = (v5.Y - oal * (td - tcpd) / 4 / tcl - tcpd / 2) * 2 * tcl / (td - tcpd);
            }
            Vector2 v35 = new Vector2(dx, v5.Y);
            Vector2 v36 = new Vector2(dx, v14.Y);
            Line line34 = new Line(v5, v35);
            line34.Lineweight = Lineweight.W25;
            line34.Layer = additionalline;
            dxf.AddEntity(line34);
            Line line35 = new Line(v14, v36);
            line35.Lineweight = Lineweight.W25;
            line35.Layer = additionalline;
            dxf.AddEntity(line35);

            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v80 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v81, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v1 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v2, v17 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line23 = { v6, v13 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v7, v12 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v8, v21 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { v20, v25 };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            Vector2[] Line27 = { v26, v11 };
            fun.drawBLine(dxf, Line27, 0.3, contour);
            Vector2[] Line28 = { v21, v18 };
            fun.drawBLine(dxf, Line28, 0.3, contour);
            Vector2[] Line29 = { v18, v19 };
            fun.drawBLine(dxf, Line29, 0.3, contour);
            Vector2[] Line30 = { v19, v20 };
            fun.drawBLine(dxf, Line30, 0.3, contour);
            Vector2[] Line31 = { v25, v24 };
            fun.drawBLine(dxf, Line31, 0.3, contour);
            Vector2[] Line32 = { v24, v23 };
            fun.drawBLine(dxf, Line32, 0.3, contour);
            Vector2[] Line33 = { v23, v26 };
            fun.drawBLine(dxf, Line33, 0.3, contour);
            //Arc Arc1 = new Arc(v22, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
            //Arc Arc2 = new Arc(v27, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
            LwPolyline Arc1 = new LwPolyline();
            Arc1.Vertexes.Add(new LwPolylineVertex(v21));
            Arc1.Vertexes.Add(new LwPolylineVertex(v20));
            Arc1.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
            fun.PolyFill(dxf, Arc1, 0.3, contour);
            LwPolyline Arc2 = new LwPolyline();
            Arc2.Vertexes.Add(new LwPolylineVertex(v25));
            Arc2.Vertexes.Add(new LwPolylineVertex(v26));
            Arc2.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
            fun.PolyFill(dxf, Arc2, 0.3, contour);
            LwPolyline Arc4 = new LwPolyline();
            Arc4.Vertexes.Add(new LwPolylineVertex(v18));
            Arc4.Vertexes.Add(new LwPolylineVertex(v19));
            Arc4.Vertexes[0].Bulge = 1 * scale / ((v18.Y - v19.Y) / 2.00);
            fun.PolyFill(dxf, Arc4, 0.3, contour);
            LwPolyline Arc5 = new LwPolyline();
            Arc5.Vertexes.Add(new LwPolylineVertex(v24));
            Arc5.Vertexes.Add(new LwPolylineVertex(v23));
            Arc5.Vertexes[0].Bulge = 1 * scale / ((v24.Y - v23.Y) / 2.00);
            fun.PolyFill(dxf, Arc5, 0.3, contour);
            Vector2[] Line38 = { v41, v42 };
            fun.drawPlinetype(dxf, Line38, 0.15, centre, Linetype.Center);
            Vector2[] Line39 = { v18, v20 };
            fun.drawBLine(dxf, Line39, 0.15, contour);
            Vector2[] Line40 = { v19, v21 };
            fun.drawBLine(dxf, Line40, 0.15, contour);
            Vector2[] Line41 = { v24, v26 };
            fun.drawBLine(dxf, Line41, 0.15, contour);
            Vector2[] Line42 = { v23, v25 };
            fun.drawBLine(dxf, Line42, 0.15, contour);
            Line Line43 = new Line(v1, v43);
            Line Line44 = new Line(v1, v44);
            Vector2[] Line55 = { v80, v81 };
            fun.drawBLine(dxf, Line55, 0.3, contour);
            Vector2[] Line56 = { v82, v8 };
            fun.drawBLine(dxf, Line56, 0.3, contour);
            Vector2[] Line57 = { v83, v11 };
            fun.drawBLine(dxf, Line57, 0.3, contour);
            Line Line58 = new Line(v89, v87);
            LwPolyline Arc3 = new LwPolyline();
            Arc3.Vertexes.Add(new LwPolylineVertex(v87));
            Arc3.Vertexes.Add(new LwPolylineVertex(v86));
            Arc3.Vertexes[0].Bulge = (v87.X - v2.X) / (v87.Y - v86.Y) * 2;
            //fun.PolyFill(dxf, Arc3, 0.1, contour);
            Arc3.Layer = contour;
            dxf.AddEntity(Arc3);
            List<Vector3> point1 = new List<Vector3>
            {
                fun.Tothree(v86),
                fun.Tothree(v90),
                fun.Tothree(v88),
                fun.Tothree(v91),
                fun.Tothree(v87),
            };
            Spline spline1 = new Spline(point1);
            spline1.Layer = contour;
            dxf.AddEntity(spline1);
            Line Line59 = new Line(v86, v92);
            LwPolyline Arc6 = new LwPolyline();
            Arc6.Vertexes.Add(new LwPolylineVertex(v85));
            Arc6.Vertexes.Add(new LwPolylineVertex(v84));
            Arc6.Vertexes[0].Bulge = h / cl;
            Arc6.Layer = contour;
            dxf.AddEntity(Arc6);
            Line Line60 = new Line(v85, v93);
            LwPolyline Arc7 = new LwPolyline();
            Arc7.Vertexes.Add(new LwPolylineVertex(v95));
            Arc7.Vertexes.Add(new LwPolylineVertex(v96));
            Arc7.Vertexes[0].Bulge = cr * (1 - Math.Sin(60 * pi / 180)) / (cr / 2);
            Arc7.Layer = contour;
            dxf.AddEntity(Arc7);
            Line Line61 = new Line(v88, v95);
            LwPolyline Arc8 = new LwPolyline();
            Arc8.Vertexes.Add(new LwPolylineVertex(v98));
            Arc8.Vertexes.Add(new LwPolylineVertex(v97));
            Arc8.Vertexes[0].Bulge = cr * (1 - Math.Sin(60 * pi / 180)) / (cr / 2);
            Arc8.Layer = contour;
            dxf.AddEntity(Arc8);
            Line Line62 = new Line(v85, v97);
            Vector2[] Line63 = { new Vector2(v4.X, v95.Y), new Vector2(v4.X, v97.Y) };
            fun.drawBLine(dxf, Line63, 0.3, contour);
            Vector2[] Line64 = { new Vector2(v5.X, v95.Y), new Vector2(v5.X, v97.Y) };
            fun.drawBLine(dxf, Line64, 0.3, contour);
            //柄方
            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(v47));
            poly1.Vertexes.Add(new LwPolylineVertex(v49));
            poly1.Vertexes.Add(new LwPolylineVertex(v50));
            poly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v52));
            poly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v53));
            poly1.Vertexes.Add(new LwPolylineVertex(v55));
            poly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v56));
            poly1.Vertexes.Add(new LwPolylineVertex(v46));
            poly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            poly1.IsClosed = true;
            fun.PolyFill(dxf, poly1, 0.3, contour);
            Line Line53 = new Line(v57, v58);
            Line Line54 = new Line(v59, v60);
            //主视图图层
            Line43.Layer = dimensioning;
            Line44.Layer = dimensioning;
            Line58.Layer = contour;
            Line59.Layer = contour;
            Line60.Layer = contour;
            Line61.Layer = contour;
            Line62.Layer = contour;
            //柄方图层
            Line53.Layer = centre;
            Line54.Layer = centre;
            Line53.Linetype = Linetype.Center;
            Line54.Linetype = Linetype.Center;
            //主视图
            dxf.AddEntity(Line43);
            dxf.AddEntity(Line44);
            dxf.AddEntity(Line58);
            dxf.AddEntity(Line59);
            dxf.AddEntity(Line60);
            dxf.AddEntity(Line61);
            dxf.AddEntity(Line62);
            //柄方
            dxf.AddEntity(Line53);
            dxf.AddEntity(Line54);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 2.5;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            /*
            Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v1, v43), new Line(v1, v44), offset, dimensionStyle);
            angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim1);*/

            //fun.jdbz2(dxf, new Line(v1, v43), new Line(v1, v44), offset * 2.5, 2.5, 0.8, 0.4, "SIG = " + Math.Round(sig / (pi / 180), 2) + "°", "", "");
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v3, v16), -v3.X + v43.X - offset - 5, 270, dimensionStyle);
            dim2.UserText = "TD = " + Math.Round(td / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            double toh = Convert.ToDouble(data["thltctrh"]);
            double tol = Convert.ToDouble(data["thltctrl"]);
            if (toh == 0 && tol == 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v17, v15), -offset, 0, dimensionStyle);
                dim3.UserText = "THL = " + Math.Round(thl / scale, 2);
                dxf.AddEntity(dim3);
            }
            else
            {
                fun.dimrot(dxf, v17, v15, 0, -offset, 2.5, 2, 2.5, "THL = " + Math.Round(thl / scale, 2), toh + "", tol + "");
            }
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v17, v13), -offset - 5, 0, dimensionStyle);
            dim4.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            double toh1 = Convert.ToDouble(data["oaltctrh"]);
            double tol1 = Convert.ToDouble(data["oaltctrl"]);
            string oaltctr = Convert.ToString(data["oaltctr"]);
            if (toh1 == 0 && tol1 == 0)
            {
                if (oaltctr.Equals("0"))
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 2, 0, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 2, 0, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2) + "  " + oaltctr;
                    dxf.AddEntity(dim5);
                }

            }
            else
            {
                fun.dimrot(dxf, v17, v10, 0, -offset * 2, 2.5, 2, 2.5, "OAL = " + Math.Round(oal / scale, 2), toh1 + "", tol1 + "");
            }

            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v23, v26), -offset - (v26.Y - v11.Y), 0, dimensionStyle);
            dim6.UserText = "DRVL = " + Math.Round(drvl / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            string tcdconws = Convert.ToString(data["tcdconws"]);
            if (tcdconws.Equals("0"))
            {
                LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim7);
            }
            else
            {
                LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2) + "  " + tcdconws;
                dxf.AddEntity(dim7);
            }

            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v46, v50), -offset, 135, dimensionStyle);
            dim8.UserText = "DRVSC = " + Math.Round(drvsc / scale, 2);
            dxf.AddEntity(dim8);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
            hatchpoly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
            hatchpoly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
            hatchpoly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
            hatchpoly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 89, 5, hline1, harc1, hatching);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v1.X - 210 + (v45.X + v8.Y - v1.X) / 2.00, v1.Y + 148.5), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void StraightFluteTapWithHole(Dictionary<string, Object> data)    //直槽带孔丝锥(细柄)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 105)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 210)
            {
                scale = 1.0;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double td = Convert.ToDouble(data["td"]) * scale;
            double dmm = Convert.ToDouble(data["dconms"]) * scale;
            double tp = Convert.ToDouble(data["tp"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            if (dn == 0)
            {
                dn = dmm;
            }
            double mc = Convert.ToDouble(data["mc"]);
            double qxzj;
            if (mc == 0)
            {
                qxzj = 4.5 * pi / 180;
            }
            if (mc == 1)
            {
                qxzj = 8.5 * pi / 180;
            }
            if (mc == 2)
            {
                qxzj = 17 * pi / 180;
            }
            else
            {
                qxzj = 6 * pi / 180;
            }

            double tcl;
            if (mc == 0)
            {
                tcl = 8 * tp;
            }
            else if (mc == 1)
            {
                tcl = 4 * tp;
            }
            else if (mc == 2)
            {
                tcl = 2 * tp;
            }
            else
            {
                tcl = 6 * tp;
            }

            if (tcl == 0)
            {
                tcl = tp * 2.3;
            }
            double tcpd = td - tcl * Math.Tan(qxzj);
            double wcf = Convert.ToDouble(data["wcf"]) * scale;
            if (wcf == 0)
            {
                wcf = td / 3;
            }
            double thl = Convert.ToDouble(data["thl"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;
            if (lu == 0)
            {
                lu = thl * 39 / 22;
            }
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
            double drvl = Convert.ToDouble(data["drvl"]) * scale;
            /*double d7 = 2.1 * scale;
            double d8 = 1 * scale;
            double d9 = 2.5 * scale;
            double d10 = 1.2 * scale;
            double l4 = 2.6 * scale;*/
            double ds = dmm - 0.08 * scale;//柄方外圆
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v2 = new Vector2(-oal / 2.00, tcpd / 2.00);
            Vector2 v3 = new Vector2(v2.X + tcl, td / 2.00);
            Vector2 v4 = new Vector2(v2.X + thl, v3.Y);
            Vector2 v5 = new Vector2((td - dn) / 2.00 + v4.X, dn / 2.00);
            Vector2 v6 = new Vector2(v2.X + lu, v5.Y);
            Vector2 v7 = new Vector2(v6.X, dmm / 2.00);
            Vector2 v8 = new Vector2(v2.X + oal - 0.15 * dmm, ds / 2);
            Vector2 v9 = new Vector2(v2.X + oal, 0.35 * dmm);
            Vector2 v10 = new Vector2(v9.X, -v9.Y);
            Vector2 v11 = new Vector2(v8.X, -v8.Y);
            Vector2 v12 = new Vector2(v7.X, -v7.Y);
            Vector2 v13 = new Vector2(v6.X, -v6.Y);
            Vector2 v14 = new Vector2(v5.X, -v5.Y);
            Vector2 v15 = new Vector2(v4.X, -v4.Y);
            Vector2 v16 = new Vector2(v3.X, -v3.Y);
            Vector2 v17 = new Vector2(v2.X, -v2.Y);
            Vector2 v19 = new Vector2(v8.X - drvl, ds / 2.00 * (Math.Sin(45 * pi / 180) * drvsc / ds - Math.Cos(45 * pi / 180) * Math.Sqrt(1 - (drvsc * drvsc) / (ds * ds))));
            Vector2 v18 = new Vector2(v19.X, drvsc * Math.Sin(45 * pi / 180) - v19.Y);
            Vector2 v20 = new Vector2(v8.X, v19.Y);
            Vector2 v21 = new Vector2(v20.X, v18.Y);
            Vector2 v22 = new Vector2(v21.X - (v18.Y - v19.Y) / 2.00 * Math.Tan(60 * pi / 180), (v18.Y + v19.Y) / 2.00);
            Vector2 v23 = new Vector2(v18.X, -v18.Y);
            Vector2 v24 = new Vector2(v19.X, -v19.Y);
            Vector2 v25 = new Vector2(v20.X, -v20.Y);
            Vector2 v26 = new Vector2(v21.X, -v21.Y);
            Vector2 v27 = new Vector2(v22.X, -v22.Y);
            Vector2 v28 = new Vector2(v2.X + lu - 3, 0);
            Vector2 v29 = new Vector2(v2.X + lu - 2 * wcf / 3.00 - 3, wcf / 3.00);
            Vector2 v30 = new Vector2(v2.X + lu - 3 * wcf / 2.00 - 3, wcf / 2.00);
            Vector2 v31 = new Vector2(v30.X, -v30.Y);
            Vector2 v32 = new Vector2(v29.X, -v29.Y);
            Vector2 v33 = new Vector2(v2.X, v30.Y);
            Vector2 v34 = new Vector2(v33.X, -v33.Y);
            double dx = v2.X;
            if (tcpd < dn)
            {
                dx = (v5.Y - oal * (td - tcpd) / 4 / tcl - tcpd / 2) * 2 * tcl / (td - tcpd);
            }
            Vector2 v35 = new Vector2(dx, v5.Y);
            Vector2 v36 = new Vector2(dx, v14.Y);
            Vector2 v37 = new Vector2(v4.X, v34.Y);
            Vector2 v38 = new Vector2(v37.X, -v37.Y);
            Vector2 v39 = new Vector2(v5.X, v38.Y);
            Vector2 v40 = new Vector2(v39.X, -v39.Y);
            Vector2 v41 = new Vector2(v2.X - 2, 0);
            Vector2 v42 = new Vector2(v9.X + 2, 0);
            Vector2 v80 = new Vector2(v8.X - drvl - 1 * scale, v7.Y);
            Vector2 v81 = new Vector2(v80.X, -v80.Y);
            Vector2 v82 = new Vector2(v80.X, ds / 2.00);
            Vector2 v83 = new Vector2(v82.X, -v82.Y);
            //柄方
            Vector2 v45 = new Vector2(105 + oal / 4.00, v8.Y - (v20.Y - v25.Y) * Math.Cos(45 * pi / 180));
            Vector2 v46 = new Vector2(v45.X - (v20.Y - v25.Y) / 2.00, v45.Y + (v20.Y - v25.Y) / 2.00);
            Vector2 v47 = new Vector2(v45.X * 2 - v46.X, v46.Y);
            Vector2 v48 = new Vector2(v45.X + v45.Y, 0);
            Vector2 v49 = new Vector2(v45.X + v46.Y, v48.Y + v47.X - v45.X);
            Vector2 v50 = new Vector2(v49.X, -v49.Y);
            Vector2 v51 = new Vector2(v45.X, -v45.Y);
            Vector2 v52 = new Vector2(v47.X, -v47.Y);
            Vector2 v53 = new Vector2(v46.X, -v46.Y);
            Vector2 v54 = new Vector2(v45.X * 2 - v48.X, v48.Y);
            Vector2 v55 = new Vector2(v45.X * 2 - v50.X, v50.Y);
            Vector2 v56 = new Vector2(v45.X * 2 - v49.X, v49.Y);
            Vector2 v57 = new Vector2(v45.X - ds / 2.00 - 2, 0);
            Vector2 v58 = new Vector2(v45.X + ds / 2.00 + 2, 0);
            Vector2 v59 = new Vector2(v45.X, ds / 2.00 + 2);
            Vector2 v60 = new Vector2(v59.X, -v59.Y);
            string tctr = Convert.ToString(data["tctr"]);
            if (!tctr.Equals("0"))
            {
                Vector2 a1 = fun.Polar(v3, fun.CalAngle(v3, v4), fun.CalDistance(v3, v4) / 2);
                Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                Line line101 = new Line(a1, a2);
                dxf.AddEntity(line101);
                fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

            }
            /*//定位孔1
            Vector2 v65 = new Vector2(v2.X, d7 / 2.00);
            Vector2 v66 = new Vector2((d7 - d8) / 2.00 * Math.Tan(60 * pi / 180) + v65.X, d8 / 2.00);
            Vector2 v67 = new Vector2(v65.X + l4, v66.Y);
            Vector2 v68 = new Vector2(d8 / 2.00 / Math.Tan(60 * pi / 180) + v67.X, 0);
            Vector2 v69 = new Vector2(v67.X, -v67.Y);
            Vector2 v70 = new Vector2(v66.X, -v66.Y);
            Vector2 v71 = new Vector2(v65.X, -v65.Y);
            //定位孔2
            Vector2 v72 = new Vector2(v9.X, d9 / 2.00);
            Vector2 v73 = new Vector2(v72.X - (d9 - d10) / 2.00 * Math.Tan(60 * pi / 180), d10 / 2.00);
            Vector2 v74 = new Vector2(v72.X - l4, v73.Y);
            Vector2 v75 = new Vector2(v74.X - d10 / 2.00 / Math.Tan(60 * pi / 180), 0);
            Vector2 v76 = new Vector2(v74.X, -v74.Y);
            Vector2 v77 = new Vector2(v73.X, -v73.Y);
            Vector2 v78 = new Vector2(v72.X, -v72.Y);*/
            //线段
            //主视图
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v80 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v81, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line18 = { v2, v17 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v4, v38 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v37, v15 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v5, v39 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v40, v14 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v6, v13 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v7, v12 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v8, v21 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { v20, v25 };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            Vector2[] Line27 = { v26, v11 };
            fun.drawBLine(dxf, Line27, 0.3, contour);
            Vector2[] Line28 = { v21, v18 };
            fun.drawBLine(dxf, Line28, 0.3, contour);
            Vector2[] Line29 = { v18, v19 };
            fun.drawBLine(dxf, Line29, 0.3, contour);
            Vector2[] Line30 = { v19, v20 };
            fun.drawBLine(dxf, Line30, 0.3, contour);
            Vector2[] Line31 = { v25, v24 };
            fun.drawBLine(dxf, Line31, 0.3, contour);
            Vector2[] Line32 = { v24, v23 };
            fun.drawBLine(dxf, Line32, 0.3, contour);
            Vector2[] Line33 = { v23, v26 };
            fun.drawBLine(dxf, Line33, 0.3, contour);
            //Arc Arc1 = new Arc(v22, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
            //Arc Arc2 = new Arc(v27, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
            LwPolyline Arc1 = new LwPolyline();
            Arc1.Vertexes.Add(new LwPolylineVertex(v21));
            Arc1.Vertexes.Add(new LwPolylineVertex(v20));
            Arc1.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
            fun.PolyFill(dxf, Arc1, 0.3, contour);
            LwPolyline Arc2 = new LwPolyline();
            Arc2.Vertexes.Add(new LwPolylineVertex(v25));
            Arc2.Vertexes.Add(new LwPolylineVertex(v26));
            Arc2.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
            fun.PolyFill(dxf, Arc2, 0.3, contour);
            LwPolyline Arc4 = new LwPolyline();
            Arc4.Vertexes.Add(new LwPolylineVertex(v18));
            Arc4.Vertexes.Add(new LwPolylineVertex(v19));
            Arc4.Vertexes[0].Bulge = 1 * scale / ((v18.Y - v19.Y) / 2.00);
            fun.PolyFill(dxf, Arc4, 0.3, contour);
            LwPolyline Arc5 = new LwPolyline();
            Arc5.Vertexes.Add(new LwPolylineVertex(v24));
            Arc5.Vertexes.Add(new LwPolylineVertex(v23));
            Arc5.Vertexes[0].Bulge = 1 * scale / ((v24.Y - v23.Y) / 2.00);
            fun.PolyFill(dxf, Arc5, 0.3, contour);
            Vector2[] Line34 = { v5, v35 };
            fun.drawBLine(dxf, Line34, 0.15, contour);
            Vector2[] Line35 = { v14, v36 };
            fun.drawBLine(dxf, Line35, 0.15, contour);
            Line Line36 = new Line(v34, v31);
            Line36.Layer = contour;
            dxf.AddEntity(Line36);
            Line Line37 = new Line(v33, v30);
            Line37.Layer = contour;
            dxf.AddEntity(Line37);
            Vector2[] Line38 = { v41, v42 };
            fun.drawPlinetype(dxf, Line38, 0.15, centre, Linetype.Center);
            Vector2[] Line39 = { v18, v20 };
            fun.drawBLine(dxf, Line39, 0.15, contour);
            Vector2[] Line40 = { v19, v21 };
            fun.drawBLine(dxf, Line40, 0.15, contour);
            Vector2[] Line41 = { v24, v26 };
            fun.drawBLine(dxf, Line41, 0.15, contour);
            Vector2[] Line42 = { v23, v25 };
            fun.drawBLine(dxf, Line42, 0.15, contour);
            List<Vector3> point1 = new List<Vector3>
            {
                fun.Tothree(v31),
                fun.Tothree(v32),
                fun.Tothree(v28),
                fun.Tothree(v29),
                fun.Tothree(v30),
            };
            Spline spline1 = new Spline(point1);
            spline1.Layer = contour;
            dxf.AddEntity(spline1);
            Vector2[] Line55 = { v80, v81 };
            fun.drawBLine(dxf, Line55, 0.3, contour);
            Vector2[] Line56 = { v82, v8 };
            fun.drawBLine(dxf, Line56, 0.3, contour);
            Vector2[] Line57 = { v83, v11 };
            fun.drawBLine(dxf, Line57, 0.3, contour);
            //柄方
            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(v47));
            poly1.Vertexes.Add(new LwPolylineVertex(v49));
            poly1.Vertexes.Add(new LwPolylineVertex(v50));
            poly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v52));
            poly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v53));
            poly1.Vertexes.Add(new LwPolylineVertex(v55));
            poly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v56));
            poly1.Vertexes.Add(new LwPolylineVertex(v46));
            poly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            poly1.IsClosed = true;
            fun.PolyFill(dxf, poly1, 0.3, contour);
            Line Line53 = new Line(v57, v58);
            Line Line54 = new Line(v59, v60);
            /*//定位孔1
            Vector2[] Line55 = { v65, v66 };
            fun.drawPlinetype(dxf, Line55, refin, Linetype.Dashed);
            Vector2[] Line56 = { v66, v67 };
            fun.drawPlinetype(dxf, Line56, refin, Linetype.Dashed);
            Vector2[] Line57 = { v67, v68 };
            fun.drawPlinetype(dxf, Line57, refin, Linetype.Dashed);
            Vector2[] Line58 = { v68, v69 };
            fun.drawPlinetype(dxf, Line58, refin, Linetype.Dashed);
            Vector2[] Line59 = { v69, v70 };
            fun.drawPlinetype(dxf, Line59, refin, Linetype.Dashed);
            Vector2[] Line60 = { v70, v71 };
            fun.drawPlinetype(dxf, Line60, refin, Linetype.Dashed);
            Vector2[] Line67 = { v66, v70 };
            fun.drawPlinetype(dxf, Line67, refin, Linetype.Dashed);
            Vector2[] Line68 = { v67, v69 };
            fun.drawPlinetype(dxf, Line68, refin, Linetype.Dashed);
            //定位孔2
            Vector2[] Line61 = { v72, v73 };
            fun.drawPlinetype(dxf, Line61, refin, Linetype.Dashed);
            Vector2[] Line62 = { v73, v74 };
            fun.drawPlinetype(dxf, Line62, refin, Linetype.Dashed);
            Vector2[] Line63 = { v74, v75 };
            fun.drawPlinetype(dxf, Line63, refin, Linetype.Dashed);
            Vector2[] Line64 = { v75, v76 };
            fun.drawPlinetype(dxf, Line64, refin, Linetype.Dashed);
            Vector2[] Line65 = { v76, v77 };
            fun.drawPlinetype(dxf, Line65, refin, Linetype.Dashed);
            Vector2[] Line66 = { v77, v78 };
            fun.drawPlinetype(dxf, Line66, refin, Linetype.Dashed);
            Vector2[] Line69 = { v74, v76 };
            fun.drawPlinetype(dxf, Line69, refin, Linetype.Dashed);
            Vector2[] Line70 = { v73, v77 };
            fun.drawPlinetype(dxf, Line70, refin, Linetype.Dashed);*/
            //柄方图层
            Line53.Layer = centre;
            Line54.Layer = centre;
            Line53.Linetype = Linetype.Center;
            Line54.Linetype = Linetype.Center;
            //柄方
            dxf.AddEntity(Line53);
            dxf.AddEntity(Line54);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 2.5;
            double offset = 10;
            //线段尺寸标注
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v3, v16), -v3.X + v2.X - offset, 270, dimensionStyle);
            dim2.UserText = "TD = " + Math.Round(td / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            double toh = Convert.ToDouble(data["thltctrh"]);
            double tol = Convert.ToDouble(data["thltctrl"]);
            if (toh == 0 && tol == 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v17, v15), -offset, 0, dimensionStyle);
                dim3.UserText = "THL = " + Math.Round(thl / scale, 2);
                dxf.AddEntity(dim3);
            }
            else
            {
                fun.dimrot(dxf, v17, v15, 0, -offset, 2.5, 2, 2.5, "THL = " + Math.Round(thl / scale, 2), toh + "", tol + "");
            }
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v17, v13), -offset*2, 0, dimensionStyle);
            dim4.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            double toh1 = Convert.ToDouble(data["oaltctrh"]);
            double tol1 = Convert.ToDouble(data["oaltctrl"]);
            string oaltctr = Convert.ToString(data["oaltctr"]);
            if (toh1 == 0 && tol1 == 0)
            {
                if (oaltctr.Equals("0"))
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset*3, 0, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 2, 0, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2) + "  " + oaltctr;
                    dxf.AddEntity(dim5);
                }

            }
            else
            {
                fun.dimrot(dxf, v17, v10, 0, -offset * 2, 2.5, 2, 2.5, "OAL = " + Math.Round(oal / scale, 2), toh1 + "", tol1 + "");
            }
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v23, v26), -offset, 0, dimensionStyle);
            dim6.UserText = "DRVL = " + Math.Round(drvl / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7

            string tcdconws = Convert.ToString(data["tcdconws"]);
            if (tcdconws.Equals("0"))
            {
                LinearDimension dim7 = new LinearDimension(new Line(v80, v81), drvl+offset, 270, dimensionStyle);
                dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim7);
            }
            else
            {
                LinearDimension dim7 = new LinearDimension(new Line(v80, v81), drvl + offset, 270, dimensionStyle);
                dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2) + "  " + tcdconws;
                dxf.AddEntity(dim7);
            }

            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v46, v50), offset, -45, dimensionStyle);
            dim8.UserText = "DRVSC = " + Math.Round(drvsc / scale, 2);
            dxf.AddEntity(dim8);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
            hatchpoly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
            hatchpoly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
            hatchpoly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
            hatchpoly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 89, 5, hline1, harc1, hatching);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v2.X - 210 + (v45.X + v8.Y - v2.X) / 2.00, 148.5), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void SpiralFluteTapWithHole(Dictionary<string, Object> data)    //螺旋槽带孔丝锥(细柄)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            //作图
            //参数
            /*         double soal = Convert.ToDouble(data["oal"]);
                     double scale = Convert.ToDouble(data["scale"]); //放大系数
                     if (scale == 0 && soal < 105)
                     {
                         scale = 2.0;
                     }
                     else if (scale == 0 && soal < 210)
                     {
                         scale = 1.0;
                     }
                     else if (scale == 0)
                     {
                         scale = 0.5;
                     }
                     double pi = Math.PI;
                     double td = Convert.ToDouble(data["td"]) * scale;
                     double dmm = Convert.ToDouble(data["dmm"]) * scale;
                     double tp = Convert.ToDouble(data["tp"]) * scale;
                     double dn = Convert.ToDouble(data["dn"]) * scale;
                     if (dn == 0)
                     {
                         dn = td - 1.1325 * tp - 0.15;
                     }
                     double mc = Convert.ToDouble(data["mc"]);
                     double qxzj;
                     if (mc == 0)
                     {
                         qxzj = 4.5 * pi / 180;
                     }
                     if (mc == 1)
                     {
                         qxzj = 8.5 * pi / 180;
                     }
                     if (mc == 2)
                     {
                         qxzj = 17 * pi / 180;
                     }
                     else
                     {
                         qxzj = 6 * pi / 180;
                     }
                     double tcl;
                     if (mc == 0)
                     {
                         tcl = 8 * tp;
                     }
                     else if (mc == 1)
                     {
                         tcl = 4 * tp;
                     }
                     else if (mc == 2)
                     {
                         tcl = 2 * tp;
                     }
                     else
                     {
                         tcl = 6 * tp;
                     }

                     if (tcl == 0)
                     {
                         tcl = tp * 2.3;
                     }
                     double tcpd = td - tcl * Math.Tan(qxzj);
                     double thl = Convert.ToDouble(data["thl"]) * scale;
                     double lu = Convert.ToDouble(data["lu"]) * scale;
                     if (lu == 0)
                     {
                         lu = thl * 39 / 22;
                     }
                     double oal = Convert.ToDouble(data["oal"]) * scale;
                     double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
                     double drvl = Convert.ToDouble(data["drvl"]) * scale;
                     double FHA = Convert.ToDouble(data["fha"]);*/
            /*double d7 = 2.1 * scale;
            double d8 = 1 * scale;
            double d9 = 2.5 * scale;
            double d10 = 1.2 * scale;
            double l4 = 2.6 * scale;                        */
            /*           double ds = dmm - 0.08 * scale;//柄方外圆
                       double isframe = Convert.ToDouble(data["isframe"]);
                       string path = Convert.ToString(data["path"]);
                       */
            double soal = 72;
            double scale = 0; //放大系数
            if (scale == 0 && soal < 105)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 210)
            {
                scale = 1.0;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double td = Convert.ToDouble(data["td"]) * scale;
            double dmm = Convert.ToDouble(data["dconms"]) * scale;
            double tp = Convert.ToDouble(data["tp"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            if (dn == 0)
            {
                dn = td - 1.1325 * tp - 0.15;
            }
            double mc = Convert.ToDouble(data["mc"]);
            double qxzj;
            if (mc == 0)
            {
                qxzj = 4.5 * pi / 180;
            }
            if (mc == 1)
            {
                qxzj = 8.5 * pi / 180;
            }
            if (mc == 2)
            {
                qxzj = 17 * pi / 180;
            }
            else
            {
                qxzj = 6 * pi / 180;
            }
            double tcl;
            if (mc == 0)
            {
                tcl = 8 * tp;
            }
            else if (mc == 1)
            {
                tcl = 4 * tp;
            }
            else if (mc == 2)
            {
                tcl = 2 * tp;
            }
            else
            {
                tcl = 6 * tp;
            }

            if (tcl == 0)
            {
                tcl = tp * 2.3;
            }
            double tcpd = td - tcl * Math.Tan(qxzj);
            double thl = Convert.ToDouble(data["thl"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;
            if (lu == 0)
            {
                lu = thl * 39 / 22;
            }
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
            double drvl = Convert.ToDouble(data["drvl"]) * scale;
            double FHA = Convert.ToDouble(data["fha"]);
            /*double d7 = 2.1 * scale;
            double d8 = 1 * scale;
            double d9 = 2.5 * scale;
            double d10 = 1.2 * scale;
            double l4 = 2.6 * scale;*/
            double ds = dmm - 0.08 * scale;//柄方外圆
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);

            //坐标
            //主视图
            Vector2 v2 = new Vector2(-oal / 2.00, tcpd / 2.00);
            Vector2 v3 = new Vector2(v2.X + tcl, td / 2.00);
            Vector2 v4 = new Vector2(v2.X + thl, v3.Y);
            Vector2 v5 = new Vector2((td - dn) / 2.00 + v4.X, dn / 2.00);
            Vector2 v6 = new Vector2(v2.X + lu, v5.Y);
            Vector2 v7 = new Vector2(v6.X, dmm / 2.00);
            Vector2 v8 = new Vector2(v2.X + oal - 0.15 * dmm, ds / 2);
            Vector2 v9 = new Vector2(v2.X + oal, 0.35 * dmm);
            Vector2 v10 = new Vector2(v9.X, -v9.Y);
            Vector2 v11 = new Vector2(v8.X, -v8.Y);
            Vector2 v12 = new Vector2(v7.X, -v7.Y);
            Vector2 v13 = new Vector2(v6.X, -v6.Y);
            Vector2 v14 = new Vector2(v5.X, -v5.Y);
            Vector2 v15 = new Vector2(v4.X, -v4.Y);
            Vector2 v16 = new Vector2(v3.X, -v3.Y);
            Vector2 v17 = new Vector2(v2.X, -v2.Y);
            Vector2 v19 = new Vector2(v8.X - drvl, ds / 2.00 * (Math.Sin(45 * pi / 180) * drvsc / ds - Math.Cos(45 * pi / 180) * Math.Sqrt(1 - (drvsc * drvsc) / (ds * ds))));
            Vector2 v18 = new Vector2(v19.X, drvsc * Math.Sin(45 * pi / 180) - v19.Y);
            Vector2 v20 = new Vector2(v8.X, v19.Y);
            Vector2 v21 = new Vector2(v20.X, v18.Y);
            Vector2 v22 = new Vector2(v21.X - (v18.Y - v19.Y) / 2.00 * Math.Tan(60 * pi / 180), (v18.Y + v19.Y) / 2.00);
            Vector2 v23 = new Vector2(v18.X, -v18.Y);
            Vector2 v24 = new Vector2(v19.X, -v19.Y);
            Vector2 v25 = new Vector2(v20.X, -v20.Y);
            Vector2 v26 = new Vector2(v21.X, -v21.Y);
            Vector2 v27 = new Vector2(v22.X, -v22.Y);
            Vector2 v41 = new Vector2(v2.X - 2, 0);
            Vector2 v42 = new Vector2(v9.X + 2, 0);
            Vector2 v80 = new Vector2(v8.X - drvl - 1 * scale, v7.Y);
            Vector2 v81 = new Vector2(v80.X, -v80.Y);
            Vector2 v82 = new Vector2(v80.X, ds / 2.00);
            Vector2 v83 = new Vector2(v82.X, -v82.Y);
            //柄方
            Vector2 v45 = new Vector2(105 + oal / 4.00, v8.Y - (v20.Y - v25.Y) * Math.Cos(45 * pi / 180));
            Vector2 v46 = new Vector2(v45.X - (v20.Y - v25.Y) / 2.00, v45.Y + (v20.Y - v25.Y) / 2.00);
            Vector2 v47 = new Vector2(v45.X * 2 - v46.X, v46.Y);
            Vector2 v48 = new Vector2(v45.X + v45.Y, 0);
            Vector2 v49 = new Vector2(v45.X + v46.Y, v48.Y + v47.X - v45.X);
            Vector2 v50 = new Vector2(v49.X, -v49.Y);
            Vector2 v51 = new Vector2(v45.X, -v45.Y);
            Vector2 v52 = new Vector2(v47.X, -v47.Y);
            Vector2 v53 = new Vector2(v46.X, -v46.Y);
            Vector2 v54 = new Vector2(v45.X * 2 - v48.X, v48.Y);
            Vector2 v55 = new Vector2(v45.X * 2 - v50.X, v50.Y);
            Vector2 v56 = new Vector2(v45.X * 2 - v49.X, v49.Y);
            Vector2 v57 = new Vector2(v45.X - ds / 2.00 - 2, 0);
            Vector2 v58 = new Vector2(v45.X + ds / 2.00 + 2, 0);
            Vector2 v59 = new Vector2(v45.X, ds / 2.00 + 2);
            Vector2 v60 = new Vector2(v59.X, -v59.Y);
            //         string tctr = Convert.ToString(data["tctr"]);
            string tctr = "0";
            if (!tctr.Equals("0"))
            {
                Vector2 a1 = fun.Polar(v3, fun.CalAngle(v3, v4), fun.CalDistance(v3, v4) / 2);
                Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                Line line101 = new Line(a1, a2);
                dxf.AddEntity(line101);
                fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

            }
            /*//定位孔1
            Vector2 v61 = new Vector2(v2.X, d7 / 2.00);
            Vector2 v62 = new Vector2((d7 - d8) / 2.00 * Math.Tan(60 * pi / 180) + v61.X, d8 / 2.00);
            Vector2 v63 = new Vector2(v61.X + l4, v62.Y);
            Vector2 v64 = new Vector2(d8 / 2.00 / Math.Tan(60 * pi / 180) + v63.X, 0);
            Vector2 v65 = new Vector2(v63.X, -v63.Y);
            Vector2 v66 = new Vector2(v62.X, -v62.Y);
            Vector2 v67 = new Vector2(v61.X, -v61.Y);
            //定位孔2
            Vector2 v68 = new Vector2(v9.X, d9 / 2.00);
            Vector2 v69 = new Vector2(v68.X - (d9 - d10) / 2.00 * Math.Tan(60 * pi / 180), d10 / 2.00);
            Vector2 v70 = new Vector2(v68.X - l4, v69.Y);
            Vector2 v71 = new Vector2(v70.X - d10 / 2.00 / Math.Tan(60 * pi / 180), 0);
            Vector2 v72 = new Vector2(v70.X, -v70.Y);
            Vector2 v73 = new Vector2(v69.X, -v69.Y);
            Vector2 v74 = new Vector2(v68.X, -v68.Y);*/
            //线段
            //主视图
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.5, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.5, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.5, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.5, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.5, contour);
            Vector2[] Line7 = { v7, v80 };
            fun.drawBLine(dxf, Line7, 0.5, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.5, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.5, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.5, contour);
            Vector2[] Line11 = { v81, v12 };
            fun.drawBLine(dxf, Line11, 0.5, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.5, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.5, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.5, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.5, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.5, contour);
            Vector2[] Line18 = { v2, v17 };
            fun.drawBLine(dxf, Line18, 0.5, contour);
            Vector2[] Line23 = { v6, v13 };
            fun.drawBLine(dxf, Line23, 0.5, contour);
            Vector2[] Line24 = { v7, v12 };
            fun.drawBLine(dxf, Line24, 0.5, contour);
            Vector2[] Line25 = { v8, v21 };
            fun.drawBLine(dxf, Line25, 0.5, contour);
            Vector2[] Line26 = { v20, v25 };
            fun.drawBLine(dxf, Line26, 0.5, contour);
            Vector2[] Line27 = { v26, v11 };
            fun.drawBLine(dxf, Line27, 0.5, contour);
            Vector2[] Line28 = { v21, v18 };
            fun.drawBLine(dxf, Line28, 0.5, contour);
            Vector2[] Line29 = { v18, v19 };
            fun.drawBLine(dxf, Line29, 0.5, contour);
            Vector2[] Line30 = { v19, v20 };
            fun.drawBLine(dxf, Line30, 0.5, contour);
            Vector2[] Line31 = { v25, v24 };
            fun.drawBLine(dxf, Line31, 0.5, contour);
            Vector2[] Line32 = { v24, v23 };
            fun.drawBLine(dxf, Line32, 0.5, contour);
            Vector2[] Line33 = { v23, v26 };
            fun.drawBLine(dxf, Line33, 0.5, contour);



            //Arc Arc1 = new Arc(v22, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
            //Arc Arc2 = new Arc(v27, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
            LwPolyline Arc1 = new LwPolyline();
            Arc1.Vertexes.Add(new LwPolylineVertex(v21));
            Arc1.Vertexes.Add(new LwPolylineVertex(v20));
            Arc1.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
            fun.PolyFill(dxf, Arc1, 0.3, contour);
            LwPolyline Arc2 = new LwPolyline();
            Arc2.Vertexes.Add(new LwPolylineVertex(v25));
            Arc2.Vertexes.Add(new LwPolylineVertex(v26));
            Arc2.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
            fun.PolyFill(dxf, Arc2, 0.3, contour);
            LwPolyline Arc4 = new LwPolyline();
            Arc4.Vertexes.Add(new LwPolylineVertex(v18));
            Arc4.Vertexes.Add(new LwPolylineVertex(v19));
            Arc4.Vertexes[0].Bulge = 1 * scale / ((v18.Y - v19.Y) / 2.00);
            fun.PolyFill(dxf, Arc4, 0.3, contour);
            LwPolyline Arc5 = new LwPolyline();
            Arc5.Vertexes.Add(new LwPolylineVertex(v24));
            Arc5.Vertexes.Add(new LwPolylineVertex(v23));
            Arc5.Vertexes[0].Bulge = 1 * scale / ((v24.Y - v23.Y) / 2.00);
            fun.PolyFill(dxf, Arc5, 0.3, contour);
            Vector2[] Line38 = { v41, v42 };
            fun.drawPlinetype(dxf, Line38, 0.15, center, Linetype.Center);
            Vector2[] Line39 = { v18, v20 };
            fun.drawBLine(dxf, Line39, 0.15, contour);
            Vector2[] Line40 = { v19, v21 };
            fun.drawBLine(dxf, Line40, 0.15, contour);
            Vector2[] Line41 = { v24, v26 };
            fun.drawBLine(dxf, Line41, 0.15, contour);
            Vector2[] Line42 = { v23, v25 };
            fun.drawBLine(dxf, Line42, 0.15, contour);
            Vector2[] Line55 = { v80, v81 };
            fun.drawBLine(dxf, Line55, 0.3, contour);
            Vector2[] Line56 = { v82, v8 };
            fun.drawBLine(dxf, Line56, 0.3, contour);
            Vector2[] Line57 = { v83, v11 };
            fun.drawBLine(dxf, Line57, 0.3, contour);
            //柄方
            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(v47));
            poly1.Vertexes.Add(new LwPolylineVertex(v49));
            poly1.Vertexes.Add(new LwPolylineVertex(v50));
            poly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v52));
            poly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v53));
            poly1.Vertexes.Add(new LwPolylineVertex(v55));
            poly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v56));
            poly1.Vertexes.Add(new LwPolylineVertex(v46));
            poly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            poly1.IsClosed = true;
            fun.PolyFill(dxf, poly1, 0.3, contour);
            Line Line53 = new Line(v57, v58);
            Line Line54 = new Line(v59, v60);
            /*//定位孔1
            Vector2[] Line55 = { v61, v62 };
            fun.drawPlinetype(dxf, Line55, refin, Linetype.Dashed);
            Vector2[] Line56 = { v62, v63 };
            fun.drawPlinetype(dxf, Line56, refin, Linetype.Dashed);
            Vector2[] Line57 = { v63, v64 };
            fun.drawPlinetype(dxf, Line57, refin, Linetype.Dashed);
            Vector2[] Line58 = { v64, v65 };
            fun.drawPlinetype(dxf, Line58, refin, Linetype.Dashed);
            Vector2[] Line59 = { v65, v66 };
            fun.drawPlinetype(dxf, Line59, refin, Linetype.Dashed);
            Vector2[] Line60 = { v66, v67 };
            fun.drawPlinetype(dxf, Line60, refin, Linetype.Dashed);
            Vector2[] Line67 = { v62, v66 };
            fun.drawPlinetype(dxf, Line67, refin, Linetype.Dashed);
            Vector2[] Line68 = { v63, v65 };
            fun.drawPlinetype(dxf, Line68, refin, Linetype.Dashed);
            //定位孔2
            Vector2[] Line61 = { v68, v69 };
            fun.drawPlinetype(dxf, Line61, refin, Linetype.Dashed);
            Vector2[] Line62 = { v69, v70 };
            fun.drawPlinetype(dxf, Line62, refin, Linetype.Dashed);
            Vector2[] Line63 = { v70, v71 };
            fun.drawPlinetype(dxf, Line63, refin, Linetype.Dashed);
            Vector2[] Line64 = { v71, v72 };
            fun.drawPlinetype(dxf, Line64, refin, Linetype.Dashed);
            Vector2[] Line65 = { v72, v73 };
            fun.drawPlinetype(dxf, Line65, refin, Linetype.Dashed);
            Vector2[] Line66 = { v73, v74 };
            fun.drawPlinetype(dxf, Line66, refin, Linetype.Dashed);
            Vector2[] Line69 = { v70, v72 };
            fun.drawPlinetype(dxf, Line69, refin, Linetype.Dashed);
            Vector2[] Line70 = { v69, v73 };
            fun.drawPlinetype(dxf, Line70, refin, Linetype.Dashed);*/
            //柄方图层
            Line53.Layer = center;
            Line54.Layer = center;
            Line53.Linetype = Linetype.Center;
            Line54.Linetype = Linetype.Center;
            //柄方
            dxf.AddEntity(Line53);
            dxf.AddEntity(Line54);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 3.5;
            double offset = 10;
            //线段尺寸标注
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v3, v16), -(v3.X - v2.X) - offset, 270, dimensionStyle);
            dim2.UserText = "TD = " + Math.Round(td / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            //         double toh = Convert.ToDouble(data["thltctrh"]);
            //         double tol = Convert.ToDouble(data["thltctrl"]);
            double toh = 0;
            double tol = 0;
            if (toh == 0 && tol == 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v17, v15), -offset, 0, dimensionStyle);
                dim3.UserText = "THL = " + Math.Round(thl / scale, 2);
                dxf.AddEntity(dim3);
            }
            else
            {
                fun.dimrot(dxf, v17, v15, 0, -offset, 2.5, 2, 2.5, "THL = " + Math.Round(thl / scale, 2), toh + "", tol + "");
            }
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v17, v13), -offset*2, 0, dimensionStyle);
            dim4.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            //          double toh1 = Convert.ToDouble(data["oaltctrh"]);
            //          double tol1 = Convert.ToDouble(data["oaltctrl"]);
            //          string oaltctr = Convert.ToString(data["oaltctr"]);
            double toh1 = 0;
            double tol1 = 0;
            string oaltctr = "0";
            if (toh1 == 0 && tol1 == 0)
            {
                if (oaltctr.Equals("0"))
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 3, 0, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 3, 0, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2) + "  " + oaltctr;
                    dxf.AddEntity(dim5);
                }

            }
            else
            {
                fun.dimrot(dxf, v17, v10, 0, -offset * 2, 2.5, 2, 2.5, "OAL = " + Math.Round(oal / scale, 2), toh1 + "", tol1 + "");
            }
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v23, v26), -offset - (v26.Y - v11.Y), 0, dimensionStyle);
            dim6.UserText = "DRVL = " + Math.Round(drvl / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            //          string tcdconws = Convert.ToString(data["tcdconws"]);
            string tcdconws = "0";
            if (tcdconws.Equals("0"))
            {
                LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim7);
            }
            else
            {
                LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2) + "  " + tcdconws;
                dxf.AddEntity(dim7);
            }

            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v46, v50), -offset, 135, dimensionStyle);
            dim8.UserText = "DRVSC = " + Math.Round(drvsc / scale, 2);
            dxf.AddEntity(dim8);
            //填充柄方
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
            hatchpoly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
            hatchpoly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
            hatchpoly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
            hatchpoly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 89, 2.5, hline1, harc1, hatching);
            /*
            //填充螺旋槽
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
            }
            var x = lu / 5.00 * Math.Tan(FHA * pi / 180);
            if (x < tcpd / 2.00)
            {
                fun.hatchsuboflinew(dxf, htype2, hnumst2, -FHA, lu / 2.00 * 8 * Math.Sin(FHA * pi / 180), hline2, contour, 0.3);
            }
            else
            {
                fun.hatchsuboflinew(dxf, htype2, hnumst2, -FHA, lu / 5.00 * 8 * Math.Sin(FHA * pi / 180), hline2, contour, 0.3);
            }
            */
            //           double lxxx = Convert.ToDouble(data["lxxx"]);
            double lxxx = 0;
            if (lxxx == 0)
            {
                Vector2 v01 = fun.Polar(v17, 90 * pi / 180, tcpd / 4);
                Vector2 v02p = fun.Polar(v01, -FHA * pi / 180, 10);
                Vector2 v02 = fun.Inters(v01, v02p, v15, v16);
                Vector2 v03 = fun.Polar(v17, 90 * pi / 180, tcpd / 6 * 4);
                Vector2 v04p = fun.Polar(v03, -FHA * pi / 180, 10);
                Vector2 v04;
                if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v03.Y - v15.Y)) * 180 / pi)
                {
                    v04 = fun.Inters(v03, v04p, v4, v15);
                }
                else
                {
                    v04 = fun.Inters(v03, v04p, v15, v16);
                }

                Vector2 v05 = new Vector2(v2.X, v2.Y);
                Vector2 v06p = fun.Polar(v05, -FHA * pi / 180, 10);
                Vector2 v06;
                if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v05.Y - v15.Y)) * 180 / pi)
                {
                    v06 = fun.Inters(v05, v06p, v4, v15);
                }
                else
                {
                    v06 = fun.Inters(v05, v06p, v15, v16);
                }
                Vector2 v07p = fun.Polar(v05, 90 * pi / 180, (v03.Y - v01.Y));
                Vector2 v08p = fun.Polar(v07p, -FHA * pi / 180, 10);
                Vector2 v07 = fun.Inters(v07p, v08p, v3, v4);
                Vector2 v08;
                if (FHA <= 90 - Math.Atan((v15.X - v07.X) / (v07.Y - v15.Y)) * 180 / pi)
                {
                    v08 = fun.Inters(v07, v08p, v4, v15);
                }
                else
                {
                    v08 = fun.Inters(v07, v08p, v15, v16);
                }




                Vector2[] Line01 = { v4, v15 };
                //fun.drawBLine(dxf, Line01, 0.3, contour);
                Line line01 = new Line(v01, v02);
                line01.Lineweight = Lineweight.W25;
                line01.Layer = additionalline;
                dxf.AddEntity(line01);
                Line line02 = new Line(v03, v04);
                line02.Lineweight = Lineweight.W25;
                line02.Layer = additionalline;
                dxf.AddEntity(line02);
                Line line03 = new Line(v05, v06);
                line03.Lineweight = Lineweight.W25;
                line03.Layer = additionalline;
                dxf.AddEntity(line03);
                Line line04 = new Line(v07, v08);
                line04.Lineweight = Lineweight.W25;
                line04.Layer = additionalline;
                dxf.AddEntity(line04);


                LwPolyline hatchpoly01 = new LwPolyline();
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v01));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v17));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v16));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v02));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v01));
                hatchpoly01.IsClosed = true;
                String[] htype01 = new String[100];
                Line[] hline01 = new Line[100];
                Arc[] harc01 = new Arc[100];
                int hnumst01 = hatchpoly01.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst01; i++)
                {
                    htype01[i] = hatchpoly01.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype01[i] == "Line")
                    {
                        hline01[i] = (Line)hatchpoly01.Explode()[i];
                    }
                    if (htype01[i] == "Arc")
                    {
                        harc01[i] = (Arc)hatchpoly01.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype01, hnumst01, 89, 5 * scale, hline01, harc01, hatching);





                LwPolyline hatchpoly02 = new LwPolyline();
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v03));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v04));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v06));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v05));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v03));
                hatchpoly02.IsClosed = true;
                String[] htype02 = new String[102];
                Line[] hline02 = new Line[102];
                Arc[] harc02 = new Arc[102];
                int hnumst02 = hatchpoly02.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst02; i++)
                {
                    htype02[i] = hatchpoly02.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype02[i] == "Line")
                    {
                        hline02[i] = (Line)hatchpoly02.Explode()[i];
                    }
                    if (htype02[i] == "Arc")
                    {
                        harc02[i] = (Arc)hatchpoly02.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype02, hnumst02, 89, 5 * scale, hline02, harc02, hatching);


                LwPolyline hatchpoly03 = new LwPolyline();
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v07));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v08));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v07));
                hatchpoly03.IsClosed = true;
                String[] htype03 = new String[103];
                Line[] hline03 = new Line[103];
                Arc[] harc03 = new Arc[103];
                int hnumst03 = hatchpoly03.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst03; i++)
                {
                    htype03[i] = hatchpoly03.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype03[i] == "Line")
                    {
                        hline03[i] = (Line)hatchpoly03.Explode()[i];
                    }
                    if (htype03[i] == "Arc")
                    {
                        harc03[i] = (Arc)hatchpoly03.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype03, hnumst03, 89, 5 * scale, hline03, harc03, hatching);



            }
            else
            {
                Vector2 v01 = fun.Polar(v17, 90 * pi / 180, tcpd / 4);
                Vector2 v02p = fun.Polar(v01, -FHA * pi / 180, 10);
                Vector2 v02 = fun.Inters(v01, v02p, v15, v16);
                Vector2 v03 = fun.Polar(v17, 90 * pi / 180, tcpd / 6 * 4);
                Vector2 v04p = fun.Polar(v03, -FHA * pi / 180, 10);
                Vector2 v04;
                if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v03.Y - v15.Y)) * 180 / pi)
                {
                    v04 = fun.Inters(v03, v04p, v4, v15);
                }
                else
                {
                    v04 = fun.Inters(v03, v04p, v15, v16);
                }

                Vector2 v05 = new Vector2(v2.X, v2.Y);
                Vector2 v06p = fun.Polar(v05, -FHA * pi / 180, 10);
                Vector2 v06;
                if (FHA <= 90 - Math.Atan((v15.X - v2.X) / (v05.Y - v15.Y)) * 180 / pi)
                {
                    v06 = fun.Inters(v05, v06p, v4, v15);
                }
                else
                {
                    v06 = fun.Inters(v05, v06p, v15, v16);
                }
                Vector2 v07p = fun.Polar(v05, 90 * pi / 180, (v03.Y - v01.Y));
                Vector2 v08p = fun.Polar(v07p, -FHA * pi / 180, 10);
                Vector2 v07 = fun.Inters(v07p, v08p, v3, v4);
                Vector2 v08;
                if (FHA <= 90 - Math.Atan((v15.X - v07.X) / (v07.Y - v15.Y)) * 180 / pi)
                {
                    v08 = fun.Inters(v07, v08p, v4, v15);
                }
                else
                {
                    v08 = fun.Inters(v07, v08p, v15, v16);
                }

                Vector2 a1 = new Vector2(v01.X, -v01.Y);
                Vector2 a2 = new Vector2(v02.X, -v02.Y);
                Vector2 a3 = new Vector2(v03.X, -v03.Y);
                Vector2 a4 = new Vector2(v04.X, -v04.Y);
                Vector2 a5 = new Vector2(v05.X, -v05.Y);
                Vector2 a6 = new Vector2(v06.X, -v06.Y);
                Vector2 a7 = new Vector2(v07.X, -v07.Y);
                Vector2 a8 = new Vector2(v08.X, -v08.Y);



                Vector2[] Line01 = { v4, v15 };
                fun.drawBLine(dxf, Line01, 0.3, contour);
                Line line01 = new Line(a1, a2);
                line01.Lineweight = Lineweight.W25;
                line01.Layer = additionalline;
                dxf.AddEntity(line01);
                Line line02 = new Line(a3, a4);
                line02.Lineweight = Lineweight.W25;
                line02.Layer = additionalline;
                dxf.AddEntity(line02);
                Line line03 = new Line(a5, a6);
                line03.Lineweight = Lineweight.W25;
                line03.Layer = additionalline;
                dxf.AddEntity(line03);
                Line line04 = new Line(a7, a8);
                line04.Lineweight = Lineweight.W25;
                line04.Layer = additionalline;
                dxf.AddEntity(line04);



                LwPolyline hatchpoly01 = new LwPolyline();
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(a1));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(a2));
                hatchpoly01.Vertexes.Add(new LwPolylineVertex(a1));
                hatchpoly01.IsClosed = true;
                String[] htype01 = new String[100];
                Line[] hline01 = new Line[100];
                Arc[] harc01 = new Arc[100];
                int hnumst01 = hatchpoly01.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst01; i++)
                {
                    htype01[i] = hatchpoly01.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype01[i] == "Line")
                    {
                        hline01[i] = (Line)hatchpoly01.Explode()[i];
                    }
                    if (htype01[i] == "Arc")
                    {
                        harc01[i] = (Arc)hatchpoly01.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype01, hnumst01, 89, 5 * scale, hline01, harc01, hatching);





                LwPolyline hatchpoly02 = new LwPolyline();
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(a3));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(a4));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(a6));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(a5));
                hatchpoly02.Vertexes.Add(new LwPolylineVertex(a3));
                hatchpoly02.IsClosed = true;
                String[] htype02 = new String[102];
                Line[] hline02 = new Line[102];
                Arc[] harc02 = new Arc[102];
                int hnumst02 = hatchpoly02.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst02; i++)
                {
                    htype02[i] = hatchpoly02.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype02[i] == "Line")
                    {
                        hline02[i] = (Line)hatchpoly02.Explode()[i];
                    }
                    if (htype02[i] == "Arc")
                    {
                        harc02[i] = (Arc)hatchpoly02.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype02, hnumst02, 89, 5 * scale, hline02, harc02, hatching);


                LwPolyline hatchpoly03 = new LwPolyline();
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(a7));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(a8));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly03.Vertexes.Add(new LwPolylineVertex(a7));
                hatchpoly03.IsClosed = true;
                String[] htype03 = new String[103];
                Line[] hline03 = new Line[103];
                Arc[] harc03 = new Arc[103];
                int hnumst03 = hatchpoly03.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst03; i++)
                {
                    htype03[i] = hatchpoly03.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype03[i] == "Line")
                    {
                        hline03[i] = (Line)hatchpoly03.Explode()[i];
                    }
                    if (htype03[i] == "Arc")
                    {
                        harc03[i] = (Arc)hatchpoly03.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype03, hnumst03, 89, 5 * scale, hline03, harc03, hatching);





            }

            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v2.X - 210 + (v45.X + v8.Y - v2.X) / 2.00, 148.5), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 5, 0, 0.6, "C");
            }
    
            fun.SetLayer(dxf);

            fun.SetByLayer(dxf);
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void SpiralPointedTapWithHole(Dictionary<string, Object> data)    //螺尖带孔丝锥(细柄)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 105)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 210)
            {
                scale = 1.0;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double td = Convert.ToDouble(data["td"]) * scale;
            double dmm = Convert.ToDouble(data["dconms"]) * scale;
            double tp = Convert.ToDouble(data["tp"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            if (dn == 0)
            {
                dn = dmm;
            }
            double mc = Convert.ToDouble(data["mc"]);
            double qxzj;
            if (mc == 0)
            {
                qxzj = 4.5 * pi / 180;
            }
            if (mc == 1)
            {
                qxzj = 8.5 * pi / 180;
            }
            if (mc == 2)
            {
                qxzj = 17 * pi / 180;
            }
            else
            {
                qxzj = 6 * pi / 180;
            }

            double tcl;
            if (mc == 0)
            {
                tcl = 8 * tp;
            }
            else if (mc == 1)
            {
                tcl = 4 * tp;
            }
            else if (mc == 2)
            {
                tcl = 2 * tp;
            }
            else
            {
                tcl = 6 * tp;
            }

            if (tcl == 0)
            {
                tcl = tp * 2.3;
            }
            double tcpd = td - tcl * Math.Tan(qxzj);
            double thl = Convert.ToDouble(data["thl"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;
            if (lu == 0)
            {
                lu = thl * 39 / 22;
            }
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double drvsc = Convert.ToDouble(data["drvsc"]) * scale;
            double drvl = Convert.ToDouble(data["drvl"]) * scale;
            /*double d7 = 2.1 * scale;
            double d8 = 1 * scale;
            double d9 = 2.5 * scale;
            double d10 = 1.2 * scale;
            double l4 = 2.6 * scale;*/
            double ds = dmm - 0.08 * scale;//柄方外圆
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v2 = new Vector2(-oal / 2.00, tcpd / 2.00);
            Vector2 v3 = new Vector2(v2.X + tcl, td / 2.00);
            Vector2 v4 = new Vector2(v2.X + thl, v3.Y);
            Vector2 v5 = new Vector2((td - dn) / 2.00 + v4.X, dn / 2.00);
            Vector2 v6 = new Vector2(v2.X + lu, v5.Y);
            Vector2 v7 = new Vector2(v6.X, dmm / 2.00);
            Vector2 v8 = new Vector2(v2.X + oal - 0.15 * dmm, ds / 2);
            Vector2 v9 = new Vector2(v2.X + oal, 0.35 * dmm);
            Vector2 v10 = new Vector2(v9.X, -v9.Y);
            Vector2 v11 = new Vector2(v8.X, -v8.Y);
            Vector2 v12 = new Vector2(v7.X, -v7.Y);
            Vector2 v13 = new Vector2(v6.X, -v6.Y);
            Vector2 v14 = new Vector2(v5.X, -v5.Y);
            Vector2 v15 = new Vector2(v4.X, -v4.Y);
            Vector2 v16 = new Vector2(v3.X, -v3.Y);
            Vector2 v17 = new Vector2(v2.X, -v2.Y);
            Vector2 v19 = new Vector2(v8.X - drvl, ds / 2.00 * (Math.Sin(45 * pi / 180) * drvsc / ds - Math.Cos(45 * pi / 180) * Math.Sqrt(1 - (drvsc * drvsc) / (ds * ds))));
            Vector2 v18 = new Vector2(v19.X, drvsc * Math.Sin(45 * pi / 180) - v19.Y);
            Vector2 v20 = new Vector2(v8.X, v19.Y);
            Vector2 v21 = new Vector2(v20.X, v18.Y);
            Vector2 v22 = new Vector2(v21.X - (v18.Y - v19.Y) / 2.00 * Math.Tan(60 * pi / 180), (v18.Y + v19.Y) / 2.00);
            Vector2 v23 = new Vector2(v18.X, -v18.Y);
            Vector2 v24 = new Vector2(v19.X, -v19.Y);
            Vector2 v25 = new Vector2(v20.X, -v20.Y);
            Vector2 v26 = new Vector2(v21.X, -v21.Y);
            Vector2 v27 = new Vector2(v22.X, -v22.Y);
            Vector2 v41 = new Vector2(v2.X - 2, 0);
            Vector2 v42 = new Vector2(v9.X + 2, 0);
            Vector2 v80 = new Vector2(v8.X - drvl - 1 * scale, v7.Y);
            Vector2 v81 = new Vector2(v80.X, -v80.Y);
            Vector2 v82 = new Vector2(v80.X, ds / 2.00);
            Vector2 v83 = new Vector2(v82.X, -v82.Y);
            //螺尖槽
            Vector2 v87 = new Vector2(v2.X + tcpd * 5 / 36, v2.Y);
            Vector2 v88 = new Vector2(v2.X + tcl + thl / 5, v87.Y - 5 * tcpd / 18);
            Vector2 v86 = new Vector2(v87.X, v87.Y - 5 * tcpd / 9);
            Vector2 v89 = new Vector2(v87.X, v87.Y + (v87.X - v2.X) * (td - tcpd) / 2 / tcl);
            Vector2 v84 = new Vector2(v87.X, -v89.Y);
            Vector2 v85 = new Vector2(v86.X + (-v88.Y - v84.Y) * (td - tcpd) / 2 / tcl, -v88.Y);
            Vector2 v90 = new Vector2((v87.X - v88.X) * v88.Y * v88.Y / (v87.Y - v88.Y) / (v87.Y - v88.Y) + v88.X, 0);
            Vector2 v91 = new Vector2(v90.X, v88.Y * 2 - v90.Y);
            Vector2 v93 = new Vector2(v88.X, v15.Y);
            double cl = Math.Sqrt((v85.Y - v84.Y) * (v85.Y - v84.Y) + (v85.X - v84.X) * (v85.X - v84.X)) / 2;
            double sr = Math.Sqrt(cl * cl + (cl * (td - tcpd) / 2 / tcl) * (cl * (td - tcpd) / 2 / tcl));
            double h = sr - (td - tcpd) * cl / 2 / tcl;
            Vector2 v94 = new Vector2(v85.X, v85.Y - sr);
            Vector2 v92 = new Vector2(v87.X, Math.Sqrt(sr * sr - (v85.X - v86.X) * (v85.X - v86.X)) + v94.Y);
            //排屑槽
            Vector2 v95 = new Vector2(v2.X + lu - 3, v88.Y);
            double cr = (v5.Y - v88.Y) * 2;
            Vector2 v96 = new Vector2(v95.X - cr * Math.Sin(60 * pi / 180), v5.Y);
            Vector2 v97 = new Vector2(v95.X, -v95.Y);
            Vector2 v98 = new Vector2(v96.X, -v96.Y);
            //柄方
            Vector2 v45 = new Vector2(105 + oal / 4.00, v8.Y - (v20.Y - v25.Y) * Math.Cos(45 * pi / 180));
            Vector2 v46 = new Vector2(v45.X - (v20.Y - v25.Y) / 2.00, v45.Y + (v20.Y - v25.Y) / 2.00);
            Vector2 v47 = new Vector2(v45.X * 2 - v46.X, v46.Y);
            Vector2 v48 = new Vector2(v45.X + v45.Y, 0);
            Vector2 v49 = new Vector2(v45.X + v46.Y, v48.Y + v47.X - v45.X);
            Vector2 v50 = new Vector2(v49.X, -v49.Y);
            Vector2 v51 = new Vector2(v45.X, -v45.Y);
            Vector2 v52 = new Vector2(v47.X, -v47.Y);
            Vector2 v53 = new Vector2(v46.X, -v46.Y);
            Vector2 v54 = new Vector2(v45.X * 2 - v48.X, v48.Y);
            Vector2 v55 = new Vector2(v45.X * 2 - v50.X, v50.Y);
            Vector2 v56 = new Vector2(v45.X * 2 - v49.X, v49.Y);
            Vector2 v57 = new Vector2(v45.X - ds / 2.00 - 2, 0);
            Vector2 v58 = new Vector2(v45.X + ds / 2.00 + 2, 0);
            Vector2 v59 = new Vector2(v45.X, ds / 2.00 + 2);
            Vector2 v60 = new Vector2(v59.X, -v59.Y);
            string tctr = Convert.ToString(data["tctr"]);
            if (!tctr.Equals("0"))
            {
                Vector2 a1 = fun.Polar(v3, fun.CalAngle(v3, v4), fun.CalDistance(v3, v4) / 2);
                Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                Line line101 = new Line(a1, a2);
                dxf.AddEntity(line101);
                fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

            }
            /*//定位孔1
            Vector2 v65 = new Vector2(v2.X, d7 / 2.00);
            Vector2 v66 = new Vector2((d7 - d8) / 2.00 * Math.Tan(60 * pi / 180) + v65.X, d8 / 2.00);
            Vector2 v67 = new Vector2(v65.X + l4, v66.Y);
            Vector2 v68 = new Vector2(d8 / 2.00 / Math.Tan(60 * pi / 180) + v67.X, 0);
            Vector2 v69 = new Vector2(v67.X, -v67.Y);
            Vector2 v70 = new Vector2(v66.X, -v66.Y);
            Vector2 v71 = new Vector2(v65.X, -v65.Y);
            //定位孔2
            Vector2 v72 = new Vector2(v9.X, d9 / 2.00);
            Vector2 v73 = new Vector2(v72.X - (d9 - d10) / 2.00 * Math.Tan(60 * pi / 180), d10 / 2.00);
            Vector2 v74 = new Vector2(v72.X - l4, v73.Y);
            Vector2 v75 = new Vector2(v74.X - d10 / 2.00 / Math.Tan(60 * pi / 180), 0);
            Vector2 v76 = new Vector2(v74.X, -v74.Y);
            Vector2 v77 = new Vector2(v73.X, -v73.Y);
            Vector2 v78 = new Vector2(v72.X, -v72.Y);*/
            //线段
            //主视图
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v80 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v81, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line18 = { v2, v17 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line23 = { v6, v13 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v7, v12 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v8, v21 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { v20, v25 };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            Vector2[] Line27 = { v26, v11 };
            fun.drawBLine(dxf, Line27, 0.3, contour);
            Vector2[] Line28 = { v21, v18 };
            fun.drawBLine(dxf, Line28, 0.3, contour);
            Vector2[] Line29 = { v18, v19 };
            fun.drawBLine(dxf, Line29, 0.3, contour);
            Vector2[] Line30 = { v19, v20 };
            fun.drawBLine(dxf, Line30, 0.3, contour);
            Vector2[] Line31 = { v25, v24 };
            fun.drawBLine(dxf, Line31, 0.3, contour);
            Vector2[] Line32 = { v24, v23 };
            fun.drawBLine(dxf, Line32, 0.3, contour);
            Vector2[] Line33 = { v23, v26 };
            fun.drawBLine(dxf, Line33, 0.3, contour);
            //Arc Arc1 = new Arc(v22, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
            //Arc Arc2 = new Arc(v27, (v18.Y - v19.Y) / 2.00 / Math.Cos(60 * pi / 180), -30, 30);
            LwPolyline Arc1 = new LwPolyline();
            Arc1.Vertexes.Add(new LwPolylineVertex(v21));
            Arc1.Vertexes.Add(new LwPolylineVertex(v20));
            Arc1.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
            fun.PolyFill(dxf, Arc1, 0.3, contour);
            LwPolyline Arc2 = new LwPolyline();
            Arc2.Vertexes.Add(new LwPolylineVertex(v25));
            Arc2.Vertexes.Add(new LwPolylineVertex(v26));
            Arc2.Vertexes[0].Bulge = -((v21.Y - v20.Y) / 2.00 / Math.Cos(60 * pi / 180) - v21.X + v22.X) / ((v21.Y - v20.Y) / 2.00);
            fun.PolyFill(dxf, Arc2, 0.3, contour);
            LwPolyline Arc4 = new LwPolyline();
            Arc4.Vertexes.Add(new LwPolylineVertex(v18));
            Arc4.Vertexes.Add(new LwPolylineVertex(v19));
            Arc4.Vertexes[0].Bulge = 1 * scale / ((v18.Y - v19.Y) / 2.00);
            fun.PolyFill(dxf, Arc4, 0.3, contour);
            LwPolyline Arc5 = new LwPolyline();
            Arc5.Vertexes.Add(new LwPolylineVertex(v24));
            Arc5.Vertexes.Add(new LwPolylineVertex(v23));
            Arc5.Vertexes[0].Bulge = 1 * scale / ((v24.Y - v23.Y) / 2.00);
            fun.PolyFill(dxf, Arc5, 0.3, contour);
            Vector2[] Line38 = { v41, v42 };
            fun.drawPlinetype(dxf, Line38, 0.15, centre, Linetype.Center);
            Vector2[] Line39 = { v18, v20 };
            fun.drawBLine(dxf, Line39, 0.15, contour);
            Vector2[] Line40 = { v19, v21 };
            fun.drawBLine(dxf, Line40, 0.15, contour);
            Vector2[] Line41 = { v24, v26 };
            fun.drawBLine(dxf, Line41, 0.15, contour);
            Vector2[] Line42 = { v23, v25 };
            fun.drawBLine(dxf, Line42, 0.15, contour);
            Vector2[] Line55 = { v80, v81 };
            fun.drawBLine(dxf, Line55, 0.3, contour);
            Vector2[] Line56 = { v82, v8 };
            fun.drawBLine(dxf, Line56, 0.3, contour);
            Vector2[] Line57 = { v83, v11 };
            fun.drawBLine(dxf, Line57, 0.3, contour);
            Line Line58 = new Line(v89, v87);
            LwPolyline Arc3 = new LwPolyline();
            Arc3.Vertexes.Add(new LwPolylineVertex(v87));
            Arc3.Vertexes.Add(new LwPolylineVertex(v86));
            Arc3.Vertexes[0].Bulge = (v87.X - v2.X) / (v87.Y - v86.Y) * 2;
            //fun.PolyFill(dxf, Arc3, 0.1, contour);
            Arc3.Layer = contour;
            dxf.AddEntity(Arc3);
            List<Vector3> point1 = new List<Vector3>
            {
                fun.Tothree(v86),
                fun.Tothree(v90),
                fun.Tothree(v88),
                fun.Tothree(v91),
                fun.Tothree(v87),
            };
            Spline spline1 = new Spline(point1);
            spline1.Layer = contour;
            dxf.AddEntity(spline1);
            Line Line59 = new Line(v86, v92);
            LwPolyline Arc6 = new LwPolyline();
            Arc6.Vertexes.Add(new LwPolylineVertex(v85));
            Arc6.Vertexes.Add(new LwPolylineVertex(v84));
            Arc6.Vertexes[0].Bulge = h / cl;
            Arc6.Layer = contour;
            dxf.AddEntity(Arc6);
            Line Line60 = new Line(v85, v93);
            LwPolyline Arc7 = new LwPolyline();
            Arc7.Vertexes.Add(new LwPolylineVertex(v95));
            Arc7.Vertexes.Add(new LwPolylineVertex(v96));
            Arc7.Vertexes[0].Bulge = cr * (1 - Math.Sin(60 * pi / 180)) / (cr / 2);
            Arc7.Layer = contour;
            dxf.AddEntity(Arc7);
            Line Line61 = new Line(v88, v95);
            LwPolyline Arc8 = new LwPolyline();
            Arc8.Vertexes.Add(new LwPolylineVertex(v98));
            Arc8.Vertexes.Add(new LwPolylineVertex(v97));
            Arc8.Vertexes[0].Bulge = cr * (1 - Math.Sin(60 * pi / 180)) / (cr / 2);
            Arc8.Layer = contour;
            dxf.AddEntity(Arc8);
            Line Line62 = new Line(v85, v97);
            Vector2[] Line63 = { new Vector2(v4.X, v95.Y), new Vector2(v4.X, v97.Y) };
            fun.drawBLine(dxf, Line63, 0.3, contour);
            Vector2[] Line64 = { new Vector2(v5.X, v95.Y), new Vector2(v5.X, v97.Y) };
            fun.drawBLine(dxf, Line64, 0.3, contour);
            //柄方
            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(v47));
            poly1.Vertexes.Add(new LwPolylineVertex(v49));
            poly1.Vertexes.Add(new LwPolylineVertex(v50));
            poly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v52));
            poly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v53));
            poly1.Vertexes.Add(new LwPolylineVertex(v55));
            poly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            poly1.Vertexes.Add(new LwPolylineVertex(v56));
            poly1.Vertexes.Add(new LwPolylineVertex(v46));
            poly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            poly1.IsClosed = true;
            fun.PolyFill(dxf, poly1, 0.3, contour);
            Line Line53 = new Line(v57, v58);
            Line Line54 = new Line(v59, v60);
            /*//定位孔1
            Vector2[] Line55 = { v65, v66 };
            fun.drawPlinetype(dxf, Line55, refin, Linetype.Dashed);
            Vector2[] Line56 = { v66, v67 };
            fun.drawPlinetype(dxf, Line56, refin, Linetype.Dashed);
            Vector2[] Line57 = { v67, v68 };
            fun.drawPlinetype(dxf, Line57, refin, Linetype.Dashed);
            Vector2[] Line58 = { v68, v69 };
            fun.drawPlinetype(dxf, Line58, refin, Linetype.Dashed);
            Vector2[] Line59 = { v69, v70 };
            fun.drawPlinetype(dxf, Line59, refin, Linetype.Dashed);
            Vector2[] Line60 = { v70, v71 };
            fun.drawPlinetype(dxf, Line60, refin, Linetype.Dashed);
            Vector2[] Line67 = { v66, v70 };
            fun.drawPlinetype(dxf, Line67, refin, Linetype.Dashed);
            Vector2[] Line68 = { v67, v69 };
            fun.drawPlinetype(dxf, Line68, refin, Linetype.Dashed);
            //定位孔2
            Vector2[] Line61 = { v72, v73 };
            fun.drawPlinetype(dxf, Line61, refin, Linetype.Dashed);
            Vector2[] Line62 = { v73, v74 };
            fun.drawPlinetype(dxf, Line62, refin, Linetype.Dashed);
            Vector2[] Line63 = { v74, v75 };
            fun.drawPlinetype(dxf, Line63, refin, Linetype.Dashed);
            Vector2[] Line64 = { v75, v76 };
            fun.drawPlinetype(dxf, Line64, refin, Linetype.Dashed);
            Vector2[] Line65 = { v76, v77 };
            fun.drawPlinetype(dxf, Line65, refin, Linetype.Dashed);
            Vector2[] Line66 = { v77, v78 };
            fun.drawPlinetype(dxf, Line66, refin, Linetype.Dashed);
            Vector2[] Line69 = { v74, v76 };
            fun.drawPlinetype(dxf, Line69, refin, Linetype.Dashed);
            Vector2[] Line70 = { v73, v77 };
            fun.drawPlinetype(dxf, Line70, refin, Linetype.Dashed);*/
            //主视图图层
            Line58.Layer = contour;
            Line59.Layer = contour;
            Line60.Layer = contour;
            Line61.Layer = contour;
            Line62.Layer = contour;
            //柄方图层
            Line53.Layer = centre;
            Line54.Layer = centre;
            Line53.Linetype = Linetype.Center;
            Line54.Linetype = Linetype.Center;
            //主视图
            dxf.AddEntity(Line58);
            dxf.AddEntity(Line59);
            dxf.AddEntity(Line60);
            dxf.AddEntity(Line61);
            dxf.AddEntity(Line62);
            //柄方
            dxf.AddEntity(Line53);
            dxf.AddEntity(Line54);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 2.5;
            double offset = 10;
            //线段尺寸标注
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v3, v16), -v3.X + v2.X - offset, 270, dimensionStyle);
            dim2.UserText = "TD = " + Math.Round(td / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            double toh = Convert.ToDouble(data["thltctrh"]);
            double tol = Convert.ToDouble(data["thltctrl"]);
            if (toh == 0 && tol == 0)
            {
                LinearDimension dim3 = new LinearDimension(new Line(v17, v15), -offset, 0, dimensionStyle);
                dim3.UserText = "THL = " + Math.Round(thl / scale, 2);
                dxf.AddEntity(dim3);
            }
            else
            {
                fun.dimrot(dxf, v17, v15, 0, -offset, 2.5, 2, 2.5, "THL = " + Math.Round(thl / scale, 2), toh + "", tol + "");
            }
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v17, v13), -offset - 5, 0, dimensionStyle);
            dim4.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            double toh1 = Convert.ToDouble(data["oaltctrh"]);
            double tol1 = Convert.ToDouble(data["oaltctrl"]);
            string oaltctr = Convert.ToString(data["oaltctr"]);
            if (toh1 == 0 && tol1 == 0)
            {
                if (oaltctr.Equals("0"))
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 2, 0, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v17, v10), -offset * 2, 0, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2) + "  " + oaltctr;
                    dxf.AddEntity(dim5);
                }

            }
            else
            {
                fun.dimrot(dxf, v17, v10, 0, -offset * 2, 2.5, 2, 2.5, "OAL = " + Math.Round(oal / scale, 2), toh1 + "", tol1 + "");
            }
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v23, v26), -offset - (v26.Y - v11.Y), 0, dimensionStyle);
            dim6.UserText = "DRVL = " + Math.Round(drvl / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            string tcdconws = Convert.ToString(data["tcdconws"]);
            if (tcdconws.Equals("0"))
            {
                LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim7);
            }
            else
            {
                LinearDimension dim7 = new LinearDimension(new Line(v80, v81), v9.X - v80.X + offset, 270, dimensionStyle);
                dim7.UserText = "DCONMS = " + Math.Round(dmm / scale, 2) + "  " + tcdconws;
                dxf.AddEntity(dim7);
            }

            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v46, v50), -offset, 135, dimensionStyle);
            dim8.UserText = "DRVSC = " + Math.Round(drvsc / scale, 2);
            dxf.AddEntity(dim8);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
            hatchpoly1.Vertexes[1].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
            hatchpoly1.Vertexes[3].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
            hatchpoly1.Vertexes[5].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
            hatchpoly1.Vertexes[7].Bulge = -Math.Tan(pi / 8);
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 89, 5, hline1, harc1, hatching);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(v2.X - 210 + (v45.X + v8.Y - v2.X) / 2.00, 148.5), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void Extrusiontap(Dictionary<string, Object> data)//挤压丝锥
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double d = Convert.ToDouble(data["td"]);
            double P = Convert.ToDouble(data["tp"]);
            double d11 = Convert.ToDouble(data["dconms"]);
            double L = Convert.ToDouble(data["oal"]);
            double l = Convert.ToDouble(data["thl"]);
            double l1 = Convert.ToDouble(data["lu"]);
            if (l1 == 0)
            {
                l1 = l * 39 / 22;
            }
            double a = Convert.ToDouble(data["drvsc"]);
            double l2 = Convert.ToDouble(data["drvl"]);
            double l5 = Convert.ToDouble(data["tcl"]) * P;
            double d12 = Convert.ToDouble(data["dn"]);

            if (d12 == 0 && l1 != 0)
            {
                Vector2 v0 = new Vector2(0, 0);
                Vector2 v2 = new Vector2(v0.X + l5, v0.Y + d / 2);
                Vector2 v1 = fun.Inters(v0, fun.Polar(v0, 90 * pi / 180, 1), v2, fun.Polar(v2, -160 * pi / 180, 1));
                Vector2 v3 = new Vector2(v0.X + l, v2.Y);
                Vector2 v4 = new Vector2(v0.X + l1, v0.Y + d11 / 2);
                Vector2 v6 = new Vector2(v0.X + L, v0.Y + (d11 / 2) - (0.45 / 1.2) * d11 / 2);
                Vector2 v5 = new Vector2(v6.X - (d11 * 0.45 / 1.2) / 2, v4.Y);
                Vector2 v7 = fun.Polar(v5, -90 * pi / 180, d11 * 0.45 / 1.2);
                Vector2 v8 = new Vector2(v6.X - l2, v7.Y);
                Vector2 v9 = new Vector2(v8.X, v5.Y);
                Vector2 v10 = fun.Polar(v1, -90 * pi / 180, 0.1 * d);
                Vector2 v11 = fun.Polar(v2, -90 * pi / 180, 0.1 * d);
                Vector2 v12 = fun.Polar(v3, -90 * pi / 180, 0.1 * d);
                Vector2 v13 = fun.Inters(v1, fun.Polar(v1, -140 * pi / 180, 1), v0, fun.Polar(v0, pi, 1));
                Vector2 v14 = fun.Inters(v5, fun.Polar(v5, -35 * pi / 180, 1), v0, fun.Polar(v0, 0, 1));
                Vector2 v15 = fun.Polar(v13, pi, d / 2);
                Vector2 v16 = fun.Polar(v14, 0, d / 2);
                Vector2 p1 = new Vector2(v1.X, -v1.Y);
                Vector2 p2 = new Vector2(v2.X, -v2.Y);
                Vector2 p3 = new Vector2(v3.X, -v3.Y);
                Vector2 p4 = new Vector2(v4.X, -v4.Y);
                Vector2 p5 = new Vector2(v5.X, -v5.Y);
                Vector2 p6 = new Vector2(v6.X, -v6.Y);
                Vector2 p7 = new Vector2(v7.X, -v7.Y);
                Vector2 p8 = new Vector2(v8.X, -v8.Y);
                Vector2 p9 = new Vector2(v9.X, -v9.Y);
                Vector2 p10 = new Vector2(v10.X, -v10.Y);
                Vector2 p11 = new Vector2(v11.X, -v11.Y);
                Vector2 p12 = new Vector2(v12.X, -v12.Y);

                Vector2 v19 = fun.Polar(v16, 0, a * 3);
                Vector2 v20 = fun.Polar(v19, 90 * pi / 180, a);
                Vector2 v21 = fun.Polar(v19, 0, a);
                Vector2 v22 = fun.Polar(v19, pi, a);
                Vector2 v23 = fun.Polar(v19, -90 * pi / 180, a);
                Vector2 v20p = fun.Polar(v19, 90 * pi / 180, a * Math.Sin(45 * pi / 180));
                Vector2 v21p = fun.Polar(v19, 0, a * Math.Sin(45 * pi / 180));
                Vector2 v22p = fun.Polar(v19, pi, a * Math.Sin(45 * pi / 180));
                Vector2 v23p = fun.Polar(v19, -90 * pi / 180, a * Math.Sin(45 * pi / 180));
                Vector2 v24 = fun.Polar(v20p, -135 * pi / 180, a / 5);
                Vector2 v25 = fun.Polar(v20p, -45 * pi / 180, a / 5);
                Vector2 v26 = fun.Polar(v21p, 135 * pi / 180, a / 5);
                Vector2 v27 = fun.Polar(v21p, -135 * pi / 180, a / 5);
                Vector2 v28 = fun.Polar(v23p, 45 * pi / 180, a / 5);
                Vector2 v29 = fun.Polar(v23p, 135 * pi / 180, a / 5);
                Vector2 v30 = fun.Polar(v22p, -45 * pi / 180, a / 5);
                Vector2 v31 = fun.Polar(v22p, 45 * pi / 180, a / 5);
                Vector2[] pp1 = { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16 };
                Vector2[] pp2 = { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12 };
                Vector2[] pp3 = { v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31 };
                fun.seevector2(dxf, "v", 0.3, 0, pp1);
                fun.seevector2(dxf, "p", 0.3, 1, pp2);
                fun.seevector2(dxf, "v", 0.3, 19, pp3);
                string tctr = Convert.ToString(data["tctr"]);
                if (!tctr.Equals("0"))
                {
                    Vector2 a1 = fun.Polar(v2, fun.CalAngle(v2, v3), fun.CalDistance(v2, v3) / 2);
                    Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                    Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                    Line line101 = new Line(a1, a2);
                    dxf.AddEntity(line101);
                    fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

                }

                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v0));
                poly1.Vertexes.Add(new LwPolylineVertex(v1));
                poly1.Vertexes.Add(new LwPolylineVertex(v2));
                poly1.Vertexes.Add(new LwPolylineVertex(v3));
                poly1.Vertexes.Add(new LwPolylineVertex(v4));
                poly1.Vertexes.Add(new LwPolylineVertex(v5));
                poly1.Vertexes[5].Bulge = -Math.Tan(180 * pi / 180 / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(v7));
                poly1.Vertexes.Add(new LwPolylineVertex(p7));
                poly1.Vertexes[7].Bulge = -Math.Tan(180 * pi / 180 / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(v0));
                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.3, contour);
                Vector2[] Line1 = { v2, p2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v3, p3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v4, p4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v6, p6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v9, v8 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v8, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { p8, p7 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { p9, p8 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { p7, v7 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                LwPolyline line11 = new LwPolyline();
                line11.Vertexes.Add(new LwPolylineVertex(v10));
                line11.Vertexes.Add(new LwPolylineVertex(v11));
                line11.Vertexes.Add(new LwPolylineVertex(v12));
                line11.Lineweight = Lineweight.W25;
                line11.Layer = additionalline;
                dxf.AddEntity(line11);
                LwPolyline line12 = new LwPolyline();
                line12.Vertexes.Add(new LwPolylineVertex(p10));
                line12.Vertexes.Add(new LwPolylineVertex(p11));
                line12.Vertexes.Add(new LwPolylineVertex(p12));
                line12.Lineweight = Lineweight.W25;
                line12.Layer = additionalline;
                dxf.AddEntity(line12);
                Vector2[] Line13 = { v15, v16 };
                fun.drawPlinetype(dxf, Line13, 0.15, centre, Linetype.Center);
                Vector2[] Line14 = { v22, v21 };
                fun.drawPlinetype(dxf, Line14, 0.15, centre, Linetype.Center);
                Vector2[] Line15 = { v20, v23 };
                fun.drawPlinetype(dxf, Line15, 0.15, centre, Linetype.Center);
                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(v31));
                poly2.Vertexes.Add(new LwPolylineVertex(v24));
                poly2.Vertexes.Add(new LwPolylineVertex(v25));
                poly2.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                poly2.Vertexes.Add(new LwPolylineVertex(v26));
                poly2.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                poly2.Vertexes.Add(new LwPolylineVertex(v27));
                poly2.Vertexes.Add(new LwPolylineVertex(v28));
                poly2.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                poly2.Vertexes.Add(new LwPolylineVertex(v29));
                poly2.Vertexes.Add(new LwPolylineVertex(v30));
                poly2.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                poly2.IsClosed = true;
                fun.PolyFill(dxf, poly2, 0.3, contour);
                LwPolyline poly3 = new LwPolyline();
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = poly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = poly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)poly2.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)poly2.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);


                Vector2[] Line16 = { v1, v13 };
                fun.drawBLine(dxf, Line16, 0.15, refin);
                Vector2[] Line17 = { v13, p1 };
                fun.drawBLine(dxf, Line17, 0.15, refin);
                Vector2[] Line18 = { v5, v14 };
                fun.drawBLine(dxf, Line18, 0.15, refin);
                Vector2[] Line19 = { v14, p5 };
                fun.drawBLine(dxf, Line19, 0.15, refin);


                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.5;
                dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1;
                double offset = 20;

                LinearDimension dim1 = new LinearDimension(new Line(v2, p2), offset, 90, dimensionStyle);
                dim1.UserText = "TD = " + d;
                dxf.AddEntity(dim1);
                LinearDimension dim2 = new LinearDimension(new Line(v1, v2), offset / 4, 0, dimensionStyle);
                dim2.UserText = "TCl = " + l5;
                dxf.AddEntity(dim2);
                double toh = Convert.ToDouble(data["thltctrh"]);
                double tol = Convert.ToDouble(data["thltctrl"]);
                if (toh == 0 && tol == 0)
                {
                    LinearDimension dim3 = new LinearDimension(new Line(p1, p3), offset / 4, 180, dimensionStyle);
                    dim3.UserText = "THl = " + l;
                    dxf.AddEntity(dim3);
                }
                else
                {
                    fun.dimrot(dxf, p1, p3, 0, -offset / 4, 1, 2, -1.5, "THL = " + l, toh + "", tol + "");
                }

                double toh1 = Convert.ToDouble(data["oaltctrh"]);
                double tol1 = Convert.ToDouble(data["oaltctrl"]);
                string oaltctr = Convert.ToString(data["oaltctr"]);
                if (toh1 == 0 && tol1 == 0)
                {
                    if (oaltctr.Equals("0"))
                    {
                        LinearDimension dim4 = new LinearDimension(new Line(p1, p6), offset, 180, dimensionStyle);
                        dim4.UserText = "OAL = " + L;
                        dxf.AddEntity(dim4);
                    }
                    else
                    {
                        LinearDimension dim4 = new LinearDimension(new Line(p1, p6), offset, 180, dimensionStyle);
                        dim4.UserText = "OAL = " + L + "  " + oaltctr;
                        dxf.AddEntity(dim4);
                    }



                }
                else
                {
                    fun.dimrot(dxf, p1, p6, 0, -offset, 1, 2, -1.5, "OAL = " + L, toh1 + "", tol1 + "");
                }
                LinearDimension dim5 = new LinearDimension(new Line(p1, p4), offset / 3 * 2, 180, dimensionStyle);
                dim5.UserText = "LU = " + l1;
                dxf.AddEntity(dim5);
                LinearDimension dim6 = new LinearDimension(new Line(p9, p6), offset / 3, 180, dimensionStyle);
                dim6.UserText = "DRVL = " + l2;
                dxf.AddEntity(dim6);
                string tcdconws = Convert.ToString(data["tcdconws"]);
                if (tcdconws.Equals("0"))
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v9, p9), offset / 3, 90, dimensionStyle);
                    dim7.UserText = "DCONMS = " + d11;
                    dxf.AddEntity(dim7);
                }
                else
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v9, p9), offset / 3, 90, dimensionStyle);
                    dim7.UserText = "DCONMS = " + d11 + "  " + tcdconws;
                    dxf.AddEntity(dim7);
                }
                LinearDimension dim10 = new LinearDimension(new Line(v29, v26), offset / 3, -135, dimensionStyle);
                dim10.UserText = "DRVSC = " + a;
                dxf.AddEntity(dim10);


            }

            if (d12 != 0 && l1 != 0)
            {

                Vector2 v0 = new Vector2(0, 0);
                Vector2 v2 = new Vector2(v0.X + l5, v0.Y + d / 2);
                Vector2 v1 = fun.Inters(v0, fun.Polar(v0, 90 * pi / 180, 1), v2, fun.Polar(v2, -160 * pi / 180, 1));
                Vector2 v3 = new Vector2(v0.X + l, v2.Y);
                Vector2 v3p1 = new Vector2(v3.X, v0.X + d12 / 2);
                Vector2 v3p = fun.Inters(v3, fun.Polar(v3, -45 * pi / 180, 1), v3p1, fun.Polar(v3p1, 0, 1));
                Vector2 v4 = new Vector2(v0.X + l1, v0.Y + d11 / 2);
                Vector2 v4p = fun.Inters(v4, fun.Polar(v4, -135 * pi / 180, 1), v3p, fun.Polar(v3p, 0, 1));
                Vector2 v6 = new Vector2(v0.X + L, v0.Y + (d11 / 2) - (0.45 / 1.2) * d11 / 2);
                Vector2 v5 = new Vector2(v6.X - (d11 * 0.45 / 1.2) / 2, v4.Y);
                Vector2 v7 = fun.Polar(v5, -90 * pi / 180, d11 * 0.45 / 1.2);
                Vector2 v8 = new Vector2(v6.X - l2, v7.Y);
                Vector2 v9 = new Vector2(v8.X, v5.Y);
                Vector2 v10 = fun.Polar(v1, -90 * pi / 180, 0.1 * d);
                Vector2 v11 = fun.Polar(v2, -90 * pi / 180, 0.1 * d);
                Vector2 v12 = fun.Polar(v3, -90 * pi / 180, 0.1 * d);
                Vector2 v13 = fun.Inters(v1, fun.Polar(v1, -140 * pi / 180, 1), v0, fun.Polar(v0, pi, 1));
                Vector2 v14 = fun.Inters(v5, fun.Polar(v5, -35 * pi / 180, 1), v0, fun.Polar(v0, 0, 1));
                Vector2 v15 = fun.Polar(v13, pi, d / 2);
                Vector2 v16 = fun.Polar(v14, 0, d / 2);
                Vector2 p1 = new Vector2(v1.X, -v1.Y);
                Vector2 p2 = new Vector2(v2.X, -v2.Y);
                Vector2 p3 = new Vector2(v3.X, -v3.Y);
                Vector2 p3p = new Vector2(v3p.X, -v3p.Y);
                Vector2 p4 = new Vector2(v4.X, -v4.Y);
                Vector2 p4p = new Vector2(v4p.X, -v4p.Y);
                Vector2 p5 = new Vector2(v5.X, -v5.Y);
                Vector2 p6 = new Vector2(v6.X, -v6.Y);
                Vector2 p7 = new Vector2(v7.X, -v7.Y);
                Vector2 p8 = new Vector2(v8.X, -v8.Y);
                Vector2 p9 = new Vector2(v9.X, -v9.Y);
                Vector2 p10 = new Vector2(v10.X, -v10.Y);
                Vector2 p11 = new Vector2(v11.X, -v11.Y);
                Vector2 p12 = new Vector2(v12.X, -v12.Y);

                Vector2 v19 = fun.Polar(v16, 0, a * 3);
                Vector2 v20 = fun.Polar(v19, 90 * pi / 180, a);
                Vector2 v21 = fun.Polar(v19, 0, a);
                Vector2 v22 = fun.Polar(v19, pi, a);
                Vector2 v23 = fun.Polar(v19, -90 * pi / 180, a);
                Vector2 v20p = fun.Polar(v19, 90 * pi / 180, a * Math.Sin(45 * pi / 180));
                Vector2 v21p = fun.Polar(v19, 0, a * Math.Sin(45 * pi / 180));
                Vector2 v22p = fun.Polar(v19, pi, a * Math.Sin(45 * pi / 180));
                Vector2 v23p = fun.Polar(v19, -90 * pi / 180, a * Math.Sin(45 * pi / 180));
                Vector2 v24 = fun.Polar(v20p, -135 * pi / 180, a / 5);
                Vector2 v25 = fun.Polar(v20p, -45 * pi / 180, a / 5);
                Vector2 v26 = fun.Polar(v21p, 135 * pi / 180, a / 5);
                Vector2 v27 = fun.Polar(v21p, -135 * pi / 180, a / 5);
                Vector2 v28 = fun.Polar(v23p, 45 * pi / 180, a / 5);
                Vector2 v29 = fun.Polar(v23p, 135 * pi / 180, a / 5);
                Vector2 v30 = fun.Polar(v22p, -45 * pi / 180, a / 5);
                Vector2 v31 = fun.Polar(v22p, 45 * pi / 180, a / 5);

                string tctr = Convert.ToString(data["tctr"]);
                if (!tctr.Equals("0"))
                {
                    Vector2 a1 = fun.Polar(v2, fun.CalAngle(v2, v3), fun.CalDistance(v2, v3) / 2);
                    Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                    Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                    Line line101 = new Line(a1, a2);
                    dxf.AddEntity(line101);
                    fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

                }

                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v0));
                poly1.Vertexes.Add(new LwPolylineVertex(v1));
                poly1.Vertexes.Add(new LwPolylineVertex(v2));
                poly1.Vertexes.Add(new LwPolylineVertex(v3));
                poly1.Vertexes.Add(new LwPolylineVertex(v3p));
                poly1.Vertexes[3].Bulge = -Math.Tan(-90 * pi / 180 / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(v4p));
                poly1.Vertexes.Add(new LwPolylineVertex(v4));
                poly1.Vertexes[5].Bulge = -Math.Tan(-90 * pi / 180 / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(v5));
                poly1.Vertexes.Add(new LwPolylineVertex(v7));
                poly1.Vertexes[7].Bulge = -Math.Tan(180 * pi / 180 / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p7));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes[9].Bulge = -Math.Tan(180 * pi / 180 / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p4p));
                poly1.Vertexes[11].Bulge = -Math.Tan(-90 * pi / 180 / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p3p));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes[13].Bulge = -Math.Tan(-90 * pi / 180 / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(v0));
                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.3, contour);
                Vector2[] Line1 = { v2, p2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v3, p3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v4, p4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v6, p6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v9, v8 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v8, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { p8, p7 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { p9, p8 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { p7, v7 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                LwPolyline line11 = new LwPolyline();
                line11.Vertexes.Add(new LwPolylineVertex(v10));
                line11.Vertexes.Add(new LwPolylineVertex(v11));
                line11.Vertexes.Add(new LwPolylineVertex(v12));
                line11.Lineweight = Lineweight.W25;
                line11.Layer = additionalline;
                dxf.AddEntity(line11);
                LwPolyline line12 = new LwPolyline();
                line12.Vertexes.Add(new LwPolylineVertex(p10));
                line12.Vertexes.Add(new LwPolylineVertex(p11));
                line12.Vertexes.Add(new LwPolylineVertex(p12));
                line12.Lineweight = Lineweight.W25;
                line12.Layer = additionalline;
                dxf.AddEntity(line12);
                Vector2[] Line13 = { v15, v16 };
                fun.drawPlinetype(dxf, Line13, 0.15, centre, Linetype.Center);
                Vector2[] Line14 = { v22, v21 };
                fun.drawPlinetype(dxf, Line14, 0.15, centre, Linetype.Center);
                Vector2[] Line15 = { v20, v23 };
                fun.drawPlinetype(dxf, Line15, 0.15, centre, Linetype.Center);
                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(v31));
                poly2.Vertexes.Add(new LwPolylineVertex(v24));
                poly2.Vertexes.Add(new LwPolylineVertex(v25));
                poly2.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                poly2.Vertexes.Add(new LwPolylineVertex(v26));
                poly2.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                poly2.Vertexes.Add(new LwPolylineVertex(v27));
                poly2.Vertexes.Add(new LwPolylineVertex(v28));
                poly2.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                poly2.Vertexes.Add(new LwPolylineVertex(v29));
                poly2.Vertexes.Add(new LwPolylineVertex(v30));
                poly2.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                poly2.IsClosed = true;
                fun.PolyFill(dxf, poly2, 0.3, contour);
                LwPolyline poly3 = new LwPolyline();
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = poly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = poly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)poly2.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)poly2.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);


                Vector2[] Line16 = { v1, v13 };
                fun.drawBLine(dxf, Line16, 0.15, refin);
                Vector2[] Line17 = { v13, p1 };
                fun.drawBLine(dxf, Line17, 0.15, refin);
                Vector2[] Line18 = { v5, v14 };
                fun.drawBLine(dxf, Line18, 0.15, refin);
                Vector2[] Line19 = { v14, p5 };
                fun.drawBLine(dxf, Line19, 0.15, refin);



                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.5;
                dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1;
                double offset = 20;

                LinearDimension dim1 = new LinearDimension(new Line(v2, p2), offset, 90, dimensionStyle);
                dim1.UserText = "TD = " + d;
                dxf.AddEntity(dim1);
                LinearDimension dim2 = new LinearDimension(new Line(v1, v2), offset / 4, 0, dimensionStyle);
                dim2.UserText = "TCl = " + l5;
                dxf.AddEntity(dim2);

                double toh = Convert.ToDouble(data["thltctrh"]);
                double tol = Convert.ToDouble(data["thltctrl"]);
                if (toh == 0 && tol == 0)
                {
                    LinearDimension dim3 = new LinearDimension(new Line(p1, p3), offset / 4, 180, dimensionStyle);
                    dim3.UserText = "THl = " + l;
                    dxf.AddEntity(dim3);
                }
                else
                {
                    fun.dimrot(dxf, p1, p3, 0, -offset / 4, 1, 2, -1.5, "THL = " + l, toh + "", tol + "");
                }
                double toh1 = Convert.ToDouble(data["oaltctrh"]);
                double tol1 = Convert.ToDouble(data["oaltctrl"]);
                string oaltctr = Convert.ToString(data["oaltctr"]);
                if (toh1 == 0 && tol1 == 0)
                {

                    if (oaltctr.Equals("0"))
                    {
                        LinearDimension dim4 = new LinearDimension(new Line(p1, p6), offset, 180, dimensionStyle);
                        dim4.UserText = "OAL = " + L;
                        dxf.AddEntity(dim4);
                    }
                    else
                    {
                        LinearDimension dim4 = new LinearDimension(new Line(p1, p6), offset, 180, dimensionStyle);
                        dim4.UserText = "OAL = " + L + "  " + oaltctr;
                        dxf.AddEntity(dim4);
                    }
                }
                else
                {
                    fun.dimrot(dxf, p1, p6, 0, -offset, 1, 2, -1.5, "OAL = " + L, toh1 + "", tol1 + "");
                }
                LinearDimension dim5 = new LinearDimension(new Line(p1, p4), offset / 3 * 2, 180, dimensionStyle);
                dim5.UserText = "LU = " + l1;
                dxf.AddEntity(dim5);
                LinearDimension dim6 = new LinearDimension(new Line(p9, p6), offset / 3, 180, dimensionStyle);
                dim6.UserText = "DRVL = " + l2;
                dxf.AddEntity(dim6);
                string tcdconws = Convert.ToString(data["tcdconws"]);
                if (tcdconws.Equals("0"))
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v9, p9), offset / 3, 90, dimensionStyle);
                    dim7.UserText = "DMM = " + d11;
                    dxf.AddEntity(dim7);
                }
                else
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v9, p9), offset / 3, 90, dimensionStyle);
                    dim7.UserText = "DMM = " + d11 + "  " + tcdconws;
                    dxf.AddEntity(dim7);
                }
                LinearDimension dim8 = new LinearDimension(new Line(v4p, p4p), offset / 5, 90, dimensionStyle);
                dim8.UserText = "DN = " + d12;
                dxf.AddEntity(dim8);
                LinearDimension dim10 = new LinearDimension(new Line(v29, v26), offset / 3, -135, dimensionStyle);
                dim10.UserText = "DRVSC = " + a;
                dxf.AddEntity(dim10);





            }

            if (l1 == 0)
            {

                Vector2 v0 = new Vector2(0, 0);
                Vector2 v2 = new Vector2(v0.X + l5, v0.Y + d / 2);
                Vector2 v1 = fun.Inters(v0, fun.Polar(v0, 90 * pi / 180, 1), v2, fun.Polar(v2, -160 * pi / 180, 1));
                Vector2 v3 = new Vector2(v0.X + l, v2.Y);
                Vector2 v4p = new Vector2(v0.X + l1, v0.Y + d11 / 2);
                Vector2 v4 = fun.Inters(v3, fun.Polar(v3, -45 * pi / 180, 1), v4p, fun.Polar(v4p, 0, 1));
                Vector2 v6 = new Vector2(v0.X + L, v0.Y + (d11 / 2) - (0.45 / 1.2) * d11 / 2);
                Vector2 v5 = new Vector2(v6.X - (d11 * 0.45 / 1.2) / 2, v4.Y);
                Vector2 v7 = fun.Polar(v5, -90 * pi / 180, d11 * 0.45 / 1.2);
                Vector2 v8 = new Vector2(v6.X - l2, v7.Y);
                Vector2 v9 = new Vector2(v8.X, v5.Y);
                Vector2 v10 = fun.Polar(v1, -90 * pi / 180, 0.1 * d);
                Vector2 v11 = fun.Polar(v2, -90 * pi / 180, 0.1 * d);
                Vector2 v12 = fun.Polar(v3, -90 * pi / 180, 0.1 * d);
                Vector2 v13 = fun.Inters(v1, fun.Polar(v1, -140 * pi / 180, 1), v0, fun.Polar(v0, pi, 1));
                Vector2 v14 = fun.Inters(v5, fun.Polar(v5, -35 * pi / 180, 1), v0, fun.Polar(v0, 0, 1));
                Vector2 v15 = fun.Polar(v13, pi, d / 2);
                Vector2 v16 = fun.Polar(v14, 0, d / 2);
                Vector2 p1 = new Vector2(v1.X, -v1.Y);
                Vector2 p2 = new Vector2(v2.X, -v2.Y);
                Vector2 p3 = new Vector2(v3.X, -v3.Y);
                Vector2 p4 = new Vector2(v4.X, -v4.Y);
                Vector2 p5 = new Vector2(v5.X, -v5.Y);
                Vector2 p6 = new Vector2(v6.X, -v6.Y);
                Vector2 p7 = new Vector2(v7.X, -v7.Y);
                Vector2 p8 = new Vector2(v8.X, -v8.Y);
                Vector2 p9 = new Vector2(v9.X, -v9.Y);
                Vector2 p10 = new Vector2(v10.X, -v10.Y);
                Vector2 p11 = new Vector2(v11.X, -v11.Y);
                Vector2 p12 = new Vector2(v12.X, -v12.Y);

                Vector2 v19 = fun.Polar(v16, 0, a * 3);
                Vector2 v20 = fun.Polar(v19, 90 * pi / 180, a);
                Vector2 v21 = fun.Polar(v19, 0, a);
                Vector2 v22 = fun.Polar(v19, pi, a);
                Vector2 v23 = fun.Polar(v19, -90 * pi / 180, a);
                Vector2 v20p = fun.Polar(v19, 90 * pi / 180, a * Math.Sin(45 * pi / 180));
                Vector2 v21p = fun.Polar(v19, 0, a * Math.Sin(45 * pi / 180));
                Vector2 v22p = fun.Polar(v19, pi, a * Math.Sin(45 * pi / 180));
                Vector2 v23p = fun.Polar(v19, -90 * pi / 180, a * Math.Sin(45 * pi / 180));
                Vector2 v24 = fun.Polar(v20p, -135 * pi / 180, a / 5);
                Vector2 v25 = fun.Polar(v20p, -45 * pi / 180, a / 5);
                Vector2 v26 = fun.Polar(v21p, 135 * pi / 180, a / 5);
                Vector2 v27 = fun.Polar(v21p, -135 * pi / 180, a / 5);
                Vector2 v28 = fun.Polar(v23p, 45 * pi / 180, a / 5);
                Vector2 v29 = fun.Polar(v23p, 135 * pi / 180, a / 5);
                Vector2 v30 = fun.Polar(v22p, -45 * pi / 180, a / 5);
                Vector2 v31 = fun.Polar(v22p, 45 * pi / 180, a / 5);

                string tctr = Convert.ToString(data["tctr"]);
                if (!tctr.Equals("0"))
                {
                    Vector2 a1 = fun.Polar(v2, fun.CalAngle(v2, v3), fun.CalDistance(v2, v3) / 2);
                    Vector2 a2 = fun.Polar(a1, 45 * pi / 180, 15);
                    Vector2 a3 = fun.Polar(a1, 45 * pi / 180, 16);
                    Line line101 = new Line(a1, a2);
                    dxf.AddEntity(line101);
                    fun.text(dxf, a3, 2, "丝锥公差带:" + tctr + "");

                }

                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v0));
                poly1.Vertexes.Add(new LwPolylineVertex(v1));
                poly1.Vertexes.Add(new LwPolylineVertex(v2));
                poly1.Vertexes.Add(new LwPolylineVertex(v3));
                poly1.Vertexes.Add(new LwPolylineVertex(v4));
                poly1.Vertexes[3].Bulge = -Math.Tan(-90 * pi / 180 / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(v5));
                poly1.Vertexes[5].Bulge = -Math.Tan(180 * pi / 180 / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(v7));
                poly1.Vertexes.Add(new LwPolylineVertex(p7));
                poly1.Vertexes[7].Bulge = -Math.Tan(180 * pi / 180 / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes[9].Bulge = -Math.Tan(-90 * pi / 180 / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(v0));
                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.3, contour);
                Vector2[] Line1 = { v2, p2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v3, p3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v4, p4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v6, p6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v9, v8 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v8, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { p8, p7 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { p9, p8 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { p7, v7 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                LwPolyline line11 = new LwPolyline();
                line11.Vertexes.Add(new LwPolylineVertex(v10));
                line11.Vertexes.Add(new LwPolylineVertex(v11));
                line11.Vertexes.Add(new LwPolylineVertex(v12));
                line11.Lineweight = Lineweight.W25;
                line11.Layer = additionalline;
                dxf.AddEntity(line11);
                LwPolyline line12 = new LwPolyline();
                line12.Vertexes.Add(new LwPolylineVertex(p10));
                line12.Vertexes.Add(new LwPolylineVertex(p11));
                line12.Vertexes.Add(new LwPolylineVertex(p12));
                line12.Lineweight = Lineweight.W25;
                line12.Layer = additionalline;
                dxf.AddEntity(line12);
                Vector2[] Line13 = { v15, v16 };

                fun.drawPlinetype(dxf, Line13, 0.15, centre, Linetype.Center);
                Vector2[] Line14 = { v22, v21 };
                fun.drawPlinetype(dxf, Line14, 0.15, centre, Linetype.Center);
                Vector2[] Line15 = { v20, v23 };
                fun.drawPlinetype(dxf, Line15, 0.15, centre, Linetype.Center);
                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(v31));
                poly2.Vertexes.Add(new LwPolylineVertex(v24));
                poly2.Vertexes.Add(new LwPolylineVertex(v25));
                poly2.Vertexes[1].Bulge = -Math.Tan(pi / 8);
                poly2.Vertexes.Add(new LwPolylineVertex(v26));
                poly2.Vertexes[3].Bulge = -Math.Tan(pi / 8);
                poly2.Vertexes.Add(new LwPolylineVertex(v27));
                poly2.Vertexes.Add(new LwPolylineVertex(v28));
                poly2.Vertexes[5].Bulge = -Math.Tan(pi / 8);
                poly2.Vertexes.Add(new LwPolylineVertex(v29));
                poly2.Vertexes.Add(new LwPolylineVertex(v30));
                poly2.Vertexes[7].Bulge = -Math.Tan(pi / 8);
                poly2.IsClosed = true;
                fun.PolyFill(dxf, poly2, 0.3, contour);
                LwPolyline poly3 = new LwPolyline();
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = poly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = poly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)poly2.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)poly2.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);


                Vector2[] Line16 = { v1, v13 };
                fun.drawBLine(dxf, Line16, 0.15, refin);
                Vector2[] Line17 = { v13, p1 };
                fun.drawBLine(dxf, Line17, 0.15, refin);
                Vector2[] Line18 = { v5, v14 };
                fun.drawBLine(dxf, Line18, 0.15, refin);
                Vector2[] Line19 = { v14, p5 };
                fun.drawBLine(dxf, Line19, 0.15, refin);


                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.5;
                dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1;
                double offset = 20;

                LinearDimension dim1 = new LinearDimension(new Line(v2, p2), offset, 90, dimensionStyle);
                dim1.UserText = "TD = " + d;
                dxf.AddEntity(dim1);
                LinearDimension dim2 = new LinearDimension(new Line(v1, v2), offset / 4, 0, dimensionStyle);
                dim2.UserText = "TCl = " + l5;
                dxf.AddEntity(dim2);
                double toh = Convert.ToDouble(data["thltctrh"]);
                double tol = Convert.ToDouble(data["thltctrl"]);
                if (toh == 0 && tol == 0)
                {
                    LinearDimension dim3 = new LinearDimension(new Line(p1, p3), offset / 4, 180, dimensionStyle);
                    dim3.UserText = "THl = " + l;
                    dxf.AddEntity(dim3);
                }
                else
                {
                    fun.dimrot(dxf, p1, p3, 0, -offset / 4, 1, 2, -1.5, "THL = " + l, toh + "", tol + "");
                }
                double toh1 = Convert.ToDouble(data["oaltctrh"]);
                double tol1 = Convert.ToDouble(data["oaltctrl"]);
                string oaltctr = Convert.ToString(data["oaltctr"]);
                if (toh1 == 0 && tol1 == 0)
                {
                    if (oaltctr.Equals("0"))
                    {
                        LinearDimension dim4 = new LinearDimension(new Line(p1, p6), offset, 180, dimensionStyle);
                        dim4.UserText = "OAL = " + L;
                        dxf.AddEntity(dim4);
                    }
                    else
                    {
                        LinearDimension dim4 = new LinearDimension(new Line(p1, p6), offset, 180, dimensionStyle);
                        dim4.UserText = "OAL = " + L + "  " + oaltctr;
                        dxf.AddEntity(dim4);
                    }
                }
                else
                {
                    fun.dimrot(dxf, p1, p6, 0, -offset, 1, 2, -1.5, "OAL = " + L, toh1 + "", tol1 + "");
                }
                LinearDimension dim6 = new LinearDimension(new Line(p9, p6), offset / 3, 180, dimensionStyle);
                dim6.UserText = "DRVL = " + l2;
                dxf.AddEntity(dim6);
                string tcdconws = Convert.ToString(data["tcdconws"]);
                if (tcdconws.Equals("0"))
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v9, p9), offset / 3, 90, dimensionStyle);
                    dim7.UserText = "DMM = " + d11;
                    dxf.AddEntity(dim7);
                }
                else
                {
                    LinearDimension dim7 = new LinearDimension(new Line(v9, p9), offset / 3, 90, dimensionStyle);
                    dim7.UserText = "DMM = " + d11 + "  " + tcdconws;
                    dxf.AddEntity(dim7);
                }
                LinearDimension dim10 = new LinearDimension(new Line(v29, v26), offset / 3, -135, dimensionStyle);
                dim10.UserText = "DRVSC = " + a;
                dxf.AddEntity(dim10);


            }

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}